Not many people consume sufficient vitamin D for their body’s needs, so most people need some sunlight to boost their vitamin D to the levels required for best health. For example, if we do not produce enough vitamin D by consuming it or being in the sun, our bodies can’t extract calcium from the food we eat, so our bodies then take it from our bones. This is why a lack of vitamin D causes brittle bones and diseases like osteoporosis.
Vitamin D is made when UV (more precisely, UVB rays) react with a compound (7-dehydrocholesterol) in the skin. The best rays for UV synthesis have wavelengths between 270–300 nm. These wavelengths are present when the UV index is greater than 3. The angle of the Sun above the horizon (at sea level) also affects the production of vitamin D because the atmosphere is thicker at lower angles and absorbs more UV. At angles greater than 45° above the horizon (at sea level), vitamin D production will be occurring, although some recent research suggests that vitamin D production may occur at angles as low as 30°. At higher altitudes, there is less (thinner) atmosphere to absorb UV from the Sun.