It's functional. A ship that is kept afloat will be colonised below the warterline by algae, mussels, clams and other sessile marine life.
This causes the ship to be less streamlined and slower.
Boats that are regularly hauled out - canoes, small dinghies - can be cleaned easily.
For larger ships, you needed to find a location where the ship could be 'careened', which is typically tying up alongside a quay and waiting for the tide to go out so the crew could scrub the bottom.
As the draught (depth of water needed to float) of ships gets larger, finding a place with a sufficiently big tidal range to do this safely gets harder.
Speed was (and still is) a huge advantage for both merchant vessels and warships, so as large ships became a more and more important element of trade and warfare, much research was devoted to underwater coatings that would resist biological fouling.
That's the reason for the difference between the paint above and below the waterline - it serves a different purpose.
Probably the first really effective antifouling wasn't a paint - it was thin sheets of copper hammered onto the hull. Copper is toxic to many marine organisms.
Copper sheathing was introduced by the Royal Navy early in the 18th Century.
More recently, paints with biotoxic properties have been used. This included lead oxides and (even now) organo-tin complexes (tetrabutyl tin). The specific paints used included "Red Lead" which is a vivid red colour. Antifouling paints today often contain pigments that echo the bright red colour of red lead.
So: like many nautical puzzles, this is a combination of evolved functional practice and tradition. And it goes back to at least the 18th century.
Sources: Naval Marine Archive