The skin can be divided into 3 layers. Keratin is what makes the skin tough. In this way the top layer of the skin is always shedding and being renewed. The epidermis also has a couple of other cell types that don't migrate to the top but instead, sort of float within the epidermis. The best known of these cells are the melanocytes, which produce Melanin.
Melanin is a brown colored protein that helps determine the color of our skin.
The difference between the fairest skinned and the darkest people is only a few grams of Melanin. The melanocytes produce more melanin when we are exposed to the sun. It's important to note however, that a tan is only partially protective. Langerhans cells are there to help ward off invaders such as bacteria. They are also probably involved in recognizing and eliminating early skin cancers.