It's called the Nelson Chequer, and originally the stripe was yellow.
Nelson's original purpose (easier identification) is explained below, and the color scheme is generally agreed to be an homage by the Royal Navy to their greatest Admiral.
Note that Nelson's popularity accomplished what various Admiralty orders failed to do: Effect a standard in ship painting.
As it was the premier navy of the day, the RN style was adopted by other navies, including the US Navy.
Sea Life in Nelson's Time, John Masefield (1905), p.14:
Till Nelson's time there was no uniformity in the painting of the exteriors of the ships. The captains used their own discretion, and followed their own tastes, in the selection and application of the colours. The most general colour-scheme was as follows:—Along the water-line, just above the ruddy gleam of the coppersheathing, was a wide black streak, running right round the ship, and reaching as high as the level of the lower gun-deck. Above this the sides were yellow, of a yellow sometimes inclining to brown, like the colour of certain varnishes, and sometimes of a brighter tint, like the colour of lemon peel. The after upper-works above the gun-decks, and the outer sides of the poops above the quarter-deck guns, were painted a vivid red or blue. This band of bright colour gradually faded, till by the time of Trafalgar it had become a very deep and dull blue, of a dingy tint that was very nearly black. A band of scarlet or pale blue, edged with gold, ran round the forecastle, and continued down the beak to the figurehead. The outsides of the port-lids were of the same colour as the sides—that is, of a brownish yellow. The stern-works were generally elaborate with gilded carving, gilt cherubs, and the like, and with red, blue, green and gold devices, such as cornucopias, drums and banners, royal arms, wreaths, etc. Round the stern of each ship, outside the glazed cabin windows (we are talking of a third-rate or 74-gun ship), ran a quarter gallery or stern walk, on which the captain could take his pleasure. The supports and rails of this walk were heavy with gold-leaf. First and second-rate ships had three and two stern walks respectively. At the bows, at the extremity of the great beakhead, was the ship's figurehead, either a ramping red lion or a plain white bust, or a shield, or some allegorical figure suggested by the name of the ship. The allegorical figure was, perhaps, the most popular among the sailors. They took great pride in keeping it in good repair, with bright gilt on its spear or helmet, red paint upon its cheeks, and pretty blue sashes wherever such appeared necessary.
The ships of Lord Howe's fleet, in 1794, appear to have been painted (externally) as follows:—The side of the ships above the line of the copper a dull brown tint; the tiers of ports a pale lemon yellow, chequered by the port-lids, the outsides of which were brown, like the sides of the ship. The gilded scrollwork, at bow and stern, was as usual. Lord Nelson is said to have painted the ships of his fleets after much the same pattern, only substituting black for the dull brown of the sides and outer port-lids. The arrangement used by him became popular. It was known as the "Nelson chequer": black sides and port-lids, and yellow streaks to mark each deck of guns. It was at first used only by those ships which had fought at Trafalgar or the Nile. In time it became the system adopted throughout the Navy. The captains of some ships preferred their own colour-schemes, and painted their vessels with red or orange streaks to mark the gun tiers. The "Nelson chequer" was, however, to become the colour arrangement generally employed. Some years after Trafalgar the lemon-yellow ribands gave place to white, which continued in use till wooden men-ofwar became obsolete. Those which remain afloat are painted black and white in the manner in use in the early sixties, when such ships ceased to be built.
Internally, the sides of the ships were painted bloodred, in order that the blood, which so often and so liberally spattered them, might not appear. The inner sides of the port-lids were painted of this colour, so that when the port-lids were opened, the brown or black of the ship's sides was diversified agreeably with scarlet squares. After Trafalgar the interiors of the ships of war were sometimes painted in other colours, according to the whims of their commanders. Green was the most common variant, but the interior of some ships was painted yellow or brown. A favourite arrangement was the white and green—white for the ship's sides and beams, and green for the waterways and coamings. White became the rule about the year 1840.