"Jack Tar" was a common English term originally used to refer to seamen of the Merchant or Royal Navy, particularly during the period of the British Empire. By World War I the term was used as a nickname for those in the U.S. Navy. Both members of the public and seafarers themselves made use of the name in identifying those who went to sea. It was not used as an offensive term and sailors were happy to use the term to label themselves.
Seamen were known to "tar" their clothes before departing on voyages, in order to make them waterproof, before the invention of waterproof fabrics. Later, they frequently wore coats and hats made from a waterproof fabric called tarpaulin. This may have been shortened to "tar" at some point.
It was common amongst seamen to fat their long hair into a ponytail and smear it with high-grade tar to prevent it getting caught in the ship's equipment. In the age of wooden sailing vessels, a ship's rigging was rope made of hemp, which would rot quickly in such a damp environment. To avoid this, the ropes and cables of the standing rig were soaked in tar, which had to be replenished by tarring.
Read more about occupations gone by the wayside: