Until now, scientists believed that Europeans lost dark pigmentation of their African ancestors as far as 40,000 years ago as they started migrating to northern regions with less sunlight. It was also assumed that the lighter skin was needed in heights so the vitamin D could be synthesized in places where there isn't as much UV light as in the tropics. Vitamin B is essential for absorbing calcium, to keep our bones healthy.
So what were allegedly the real reasons for lighter skin? To quote LiveScience
,"In the food-production theory, the cereal-rich diet of Neolithic farmers lacked vitamin D, so Europeans rapidly lost their dark-skin pigmentation only once they switched to agriculture, because it was only at that point that they had to synthesize vitamin D from the sun more readily."