Melanin, the skin's brown pigment, located in the epidermis or outer skin layer and which is controlled by at least 6 genes. Both light and dark complexioned people have melanin. Both light and dark complexioned people have melanin. However, two forms are produced--pheomelanin which is red to yellow in color, and eumelanin which is dark brown to black. People with light complexioned skin mostly produce pheomelanin, while those with dark colored skin mostly produce eumelanin. In addition, individuals differ in the number and size of melanin particles. The latter two variables are more important in determining skin color than the percentages of the different kinds of melanin. In lighter skin, color is also affected by red cells in blood flowing close to the skin. To a lesser extent, the color is affected by the presence of fat under the skin and carotene, a reddish-orange pigment in the skin. Hair color is also due to the presence of melanin.
Melanin is a natural sunscreen that protects tropical peoples from the many harmful effects of ultraviolet (UV) rays. UV rays can, for example, strip away folic acid, a nutrient essential to the development of healthy fetuses. Yet when a certain amount of UV rays penetrates the skin, it helps the human body use vitamin D to absorb the calcium necessary for strong bones. This delicate balancing act explains why the peoples that migrated to colder geographic zones with less sunlight developed lighter skin color. As people moved to areas farther from the equator with lower UV levels, natural selection favored lighter skin which allowed UV rays to penetrate and produce essential vitamin D. The darker skin of peoples who lived closer to the equator was important in preventing folate deficiency. Measures of skin reflectance, a way to quantify skin color by measuring the amount of light it reflects, in people around the world support this idea. While UV rays can cause skin cancer, because skin cancer usually affects people after they have had children, it likely had little effect on the evolution of skin color because evolution favors changes that improve reproductive success.
There is also a third factor which affects skin color: coastal peoples who eat diets rich in seafood enjoy this alternate source of vitamin D. That means that some Arctic peoples, such as native peoples of Alaska and Canada, can afford to remain dark-skinned even in low UV areas. In the summer they get high levels of UV rays reflected from the surface of snow and ice, and their dark skin protects them from this reflected light.
Ref:
http://humanorigins.si.edu/evidence/genetics/human-skin-color-variation/modern-human-diversity-skin-color"Skin Color Adaptation". Retrieved December 02, 2017 from
https://www2.palomar.edu/anthro/adapt/adapt_4.htm