It is well known that depigmentation in humans was caused because of the need of vitamin D generation at the skin, but what was not so clear was why pigmentation, dark skin (conventionally called black, though it's actually brown in most cases) first evolved.
Researchers from Pennsylvania State University have now concluded that skin cancer, which is a quite weak selective pressure, is not the main reason for dark skin but the protection of folate (folic acid, vitamin B9) from being destroyed by the ultraviolet radiation.
Much like vitamin D deficiency can cause major problems in newborns, folate deficiency also does, causing neural tube defects, anemia, low birth weight and premature births. Additionally, it also affects, although less severely, adults, causing weakness, depression, weight loss, headaches and behavioral disorders.
Nina G. Jablonski and George Chaplin, Human skin pigmentation as an adaptation to UV radiation. PNAS 2010. Freely accessible (it seems).
Also discussed at Science Daily.