The UV theory is probably correct, essentially. But WHEN light skin showed up, in large portions of the Eurasian population, is in question. Researchers seem to agree, now, that there was interbreeding between us “modern” humans (AMH’s) and Neanderthals, at some point, or a few points, But WHEN those conjugations took place is not well pinned down. Neanderthals were, apparently, light skinned with straight hair. The genes that they shared may have resulted in the straight hair showing up, commonly, sooner than the light skin began showing up, commonly, in Asian and Eurasian AMH populations. The light skin may not have been particularly adaptive until a shift occurred on a broad scale dietarily, due to the advent of people surviving more on an agricultural based diet. (Then, low vitamin D may have been more of a survival to reproduction issue.) If straight hair showed up sooner, my best guess is that it, sometimes, offered a reproductive advantage in attracting mates. (No offense, kinky haired people. You are beautiful, too.)
It has been suggested by some research, that Neanderthal interbreeding also probably caused AMH males (that were a product of such) to be less fertile. But, nevertheless, some Neanderthal genes remained, in what became AMH Asian and European populations. ( I presume that these genes, that can effect skin and hair, were passed on, primarily thru female progeny, but that is just my guess). One genomic statistical analysis, in 2008, of genomes suggested the possibility that light skin only became widespread in the European population as late as 11,000 years ago. Another article that I read suggested that light skin in the population only became common even more recently, - like maybe 7,000 years ago (with the broader advent of agricultural based groups).
Still, the whole deal with suppositions like this, is that they are the best guesses of what anthropologists and geneticists have come up with, so far. It seems to me like trying to make sense of a 10,000 piece jigsaw puzzle, when they have only a rather random 100 pieces.
But we do know that we need Vitamin D. The relatives of our ancestors who didn’t get enough, probably, mostly died before they could reproduce. But our actual ancestors did not die, else, we wouldn’t be here. So those of us AMH’s with Eurasian heritage, very well might not be here, if some of our ancestors had not conjugated with Neanderthals.