As you might guess, human evolution explains a lot about the color of our skin. A product created by our bodies known as melanin helps to explain the phenomenon. The main functions of melanin are to absorb sunlight and to protect the skin from solar radiation. While these functions may seem at odds with one another, they point to the fact that our bodies actually need some sun in order to survive. Melanin allows the body to absorb a certain amount of sunlight, and helps to protect it when we've gotten too much.
Melanin is a pigment created by our bodies.
Skin cells known as melanocytes take the melanin and then package it into little critters known as melanosomes, and then disperse the melanosomes throughout our skin and hair. How naturally dark or light one's skin is is partially determined by the amount of melanin produced and how it's dispersed. And how much melanin is produced and where it's dispersed are dependent on a number of factors, including where we live and the amount of sunlight we receive. Free radicals have been implicated as causative factors in cancer. Fortunately, the atmosphere screens us from most radiation of shorter wavelength than visible light, except for part of the ultraviolet range.