Actually, there is still not 100% agreement among physical anthropologists about the causes for different skin pigmentation in humans
The most commonly accepted theory is the one Cywr mentioned: sunlight would dictate the skin tone by two mechanisms: light skins in sunny climates are affected by sunburns and higher frequency of skin cancer; dark skins in less sunny places would not be able to sinthetize enough precursors of Vitamin D, so to cause skin and bone illness for the lack of this latter.
Above is the famous map of human skin pigmentation collected by R. Biasutti for native populations prior to 1940.
We can certainly notice that, at least qualitatively, it seems to confirm that theory, since people with more intense pigmentation are predominantly located in the tropical/equatorial belt.
This scheme works very well for the Europe+Africa+Mid East+India Area.
It's worth to mention the fact that just above the tropics, where sunlight dramatically changes during the year, people developped the ability to vary the skin tone by tanning. The ability to tan varies, and is particularly strong in the Mediterranean basin. Here follow some examples:
Maria Grazia Cucinotta (Actress, Sicilian)
Carla Collado (model, Spanish)
Evelina Papantoniou (Model, Greek)
[I confide these examples helped to keep my readers attention]
In the Americas (please remember, only Native Americans/Indians/Indios are considered here, not last few centuries immigrants), a milder version of that same pattern is visible. This can be explained with the fact that Americas have been inhabited for a lot less time than the old world, and you need many many millennia for natural selection to operate.
Please consider also that the advantage or disadvantage for having or not the right skin tone for a certain environment is just marginal, so adaptation has to be rather slow.
However the Est Asia-Pacific region is quite puzzling. Most places in this area have been inhabited for very long time, and yet 1) Malaysians and Indonesians, while darker skinned than other East Asians, are not as dark as other peoples living at the same latitudes; 2) Australians aborigens are nearly as dark as Africans . . . but they are too at South! How comes they did not lose pigment? 3) most East Asians are approx. pigmented the same way, even though they live at fairly different latitudes, and certainly should have had the time to adapt.
It's certainly strange that, if extreme skin depigmentation (with the probably useless but genetically linked hair and eye blondism) is so useful to live in the North of the planet, it never diffused in Asia.
It's also peculiar that, even where blondism is common, it always co-exists with brunet and intermediate types. If it's necessary to be blond or red haired, blue or grey or green eyed, why is not everybody so?
Well, more recent studies put in evidence that, while light skin do suffer when exposed to intense light, the correlation between little light and need for depigmented skin is less strong.
For instance, the a/m inuits (eskimo) are certainly relatively dark-skinned for their environment: however, they eat a lot of fish, seals and other animal food that supply them of the necessary D vitamin.
Moreover, it has been proven that a dark-skinned person who lives in Scandinavia, while not being able to produce enough D vitamin during winter time, can produce a lot of it during summer, and since D vitamin endures for long time in the organism, the summer-produced reserve is more than enough for the whole year. That, of course, providing that that black person is exposed to sunlight for enough time during summer.
In other words, the problem of dark skins in low-sun places can be overcame by culture.
But then, where does European blondism (as well as the incipient blondism that can be found in other neighbouring populations, like North-Africans, Mid-Easterners and even Indians, as Cywr mentioned) comes from?
Well, some researchers suppose it's just a mutation (a sort of mild albinism) that, for some not well known genetic reason, is common among so-called Caucasians.
Without check it would tend to spread since all Caucasians and near-Caucasians where blond, pale and blue-eyed; however, sunny environments keep it under control
Where the sun is not so scorching, fair and red heads have no problems (and even a mild advantage at generating D vitamin), so they spread, but always mixed with black or dark brown haired and eyed people, whom the selective pressure is not able to eliminate.