Vitamin D is key in the metabolism of calcium. In fact the migration of early marine life onto land was only possible because Vitamin D made the development of strong bones possible, which could support mammals on land. Really the origins of Vitamin D can be traced back over 750 million years to single cell organism, however in terms of human history it has played a vital role all along. Our hunter-gatherer ancestors have always been exposed to strong sunlight and the darker complexion of peoples that live closer to the equator are testament to this history. In fact if you have darker skin and live north of 37 degrees latitude you really aren't able to make enough Vitamin D (in which case you need to supplement). The Neanderthal's demise may very well have had to do Vitamin D deficiency as well. Their bow-legged bone structure and stooped posture was a sign of severe calcium imbalances likely due to Vitamin D deficiency.
In more recent times, it was during the Industrial Revolution when more and more people began living in big smoggy cities, seeing less and less sun. At the turn of the 20th century it was discovered that sunlight caused the skin to produce Vitamin D, it was estimated that close to 80% of kids living in Northern Europe and the Northeastern United States suffered from rickets, which is a bone deforming disease. Heliotherapy (exposing people to sunlight) became increasingly popular and was prescribed for the treatment of rickets, tuberculosis and psoriasis. And although it worked, it fell out of favor and instead the use of antibiotics, vaccinations and other drugs were heavily promoted. During the 1960s the pharmaceutical industry began to shift public perception, regarding the risk of skin-cancer and premature wrinkling due to sun over-exposure. All of a sudden we began to think of the sun as "bad"! It should be noted that it has been known since 1937 that, yes, over exposure to strong sunlight can increase the risk of skin cancer (generally easily treatable), but that UV sunlight can actually protect you from many more, and much more deadly cancers. Non-melanoma skin cancer has a death rate of 0.5%, while internal cancers such as colon and breast cancer can have death rates of 20%-65%. In fact there is even evidence that increased sun exposure can increase survival rates for melanoma, which is a more deadly form of skin cancer!
I hope you are getting the point, Vitamin D is absolutely vital for good health and sunlight is not bad! Sunlight has always, since the beginning of time, been essential for life and it is still today vital for our well being. Sunscreen with SPF 30 will eliminate 99% of your skin's ability to manufacture Vitamin D. If you give yourself 15 to 30 minutes of strong full body sunlight, when the sun is highest in the sky, you will have plenty of Vitamin D! The rest of the time, you can moderate your exposure by covering yourself and wearing a hat. Just don't let your skin burn.