Have you ever wondered why your skin has a pigment (a color)? The answer to this question is Melanin. Melanin gives you your skin color. If your skin is white then your skin's Melanin is in the upper layers of it, and if your skin is black then Melanin is in all the layers of your skin. Some people have an orange pigment (carotene) that makes their skin look yellowish. Freckles are places which have a higher concentration of Melanin than in the rest of your skin.
Albinism is a genetic condition which turns skin and hair white and makes your eyes pale. This condition only happens to people whose bodies do not produce any Melanin.
The most important role of Melanin is that it absorbs UV rays to protect your skin. When you stay too long in sunlight, Melanin is produced thus causing sun tan.