Could the sun possibly protect us from cancer? Why has skin cancer increased over 200% the past 3 decades despite the heavy use of sunscreen? Logically speaking, how could the sun be so harmful when humans evolved near the equator and need vitamin D for health? Most people stay inside at school, work, or home nearly 11 months of the year. When they do go outside, they’re covered with clothes and sunscreen. Sunscreen blocks UVB rays needed for vitamin D synthesis. As a result, an estimated *100 million people* in America are deficient in vitamin D. Maybe this is why we have higher rates of osteoporosis than other countries even though we consume more calcium, as this vitamin is needed for calcium absorption.
This vitamin (actually a hormone) is also crucial for immune function, cancer protection, serotonin synthesis, and influences many genes.
Clearly we don’t want to be burned, but gradually increasing exposure will gradually increase melanin synthesis (skin tan), which dissipates 99% of UV rays to offer protection. It’s our natural sunscreen. You may be surprised to hear that outdoor workers have lower rates of of skin cancer compared to indoor workers. Epidemiologists found light-skinned women who had high amounts of long-term sun exposure had HALF the risk of developing advanced breast cancer 
Another large-scale, placebo controlled study showed adequate vitamin D could reduce cancer risk by 60%.  When our skin cells are exposed to sunlight, they manufacture vitamin D, which has been shown to influence expression of over *913 genes*.  Considering the evidence, researchers have been questioning whether sunlight is the main cause malignant melanoma. In fact, it’s not uncommon for people to develop melanoma on the bottom of their foot, known as acrolentiginous melanoma. Some develop melanoma in the mucous membranes.
A long-term follow up study of 260 patients in Italy found that intermittent sun exposure was inversely associated with the risk of death of melanoma patients. 
For you nerds wanting more detail, calciferol (vitamin D) has been found to inhibit angiogenesis. It also inhibits cancer cell proliferation by increasing the activity of the CDKIs p21, p27 and induce cell cycle arrest at G1 phase. [5, 6] It’s also found to decrease the expression of c-myc (a proto-oncogene), c-fos gene (another proto-oncogene) and stimulation of p53. [7, 8] Researchers have found that epidermal growth factor (EGF) made by cancer cells can be counteracted by calciferol and impact the Ras/Raf pathway.  The various pathways and biomarkers that vitamin D improves in cancer (and immunity, neurotransmission, etc.) does not stop here. http://aje.oxfordjournals.org/content/166/12/1409.abstract