Vitamin D fulfills extremely important tasks in the body, ranging from bone health to immune functions. Unlike other vitamins, vitamin D is technically a hormone, and every single cell in the body contains a receptor for it. The vitamin D receptor regulates more than 900 different genes. 
The body can synthesize vitamin D from cholesterol when the skin is exposed to sunlight (specifically UVB radiation). Vitamin D deficiencies are very common. Usually, 30-80 nanograms per mL are considered as optimal. However, according to a 2011 study, about 40% of adults in the US are deficient. This number goes up to 70% in Hispanics and 82% in African-Americans. 
This is most likely due to our modern way of living, as we eat less food that contains vitamin D and spend more time indoors. Another study from 2007 found that around 40% of people living in Miami were vitamin D deficient, which shows that the deficiency is also common in areas with year-round sunny weather. 
Symptoms of Vitamin D deficiency
Even though vitamin D deficiencies are common, many people don't realize that they are deficient, as symptoms might be subtle. Here are the most common symptoms of vitamin D deficiency, including studies that used vitamin D supplementation to improve the health status:
Vitamin D was originally discovered as something in Cod Liver Oil that cured Rickets, a condition that results in weak or soft bones in children. Later on, the same researcher found that sun light was equally protective.
The strongest evidence regarding the benefit of Vitamin D on bone health comes from studies in elderly people. Randomized control studies have repeatedly show that vitamin D supplementation decreases the risk for bone fractures [7, 8, 9]
As for the mechanism: Vitamin D enhances absorption of calcium, stimulates the differentiation of bone producing cells and increases calcium reabsorption of the bone itself.
Vitamin D also has effects on our immune system. Observational studies associate low vitamin D levels with increased susceptibility to infections. A study found that respiratory tract infections were significantly increased people with vitamin D deficiency. 
As observational studies only provide weak, correlation-based evidence it is important to look at the gold-standard of nutritional research - randomized controlled trials (RCTs)
Fortunately, there have been clinical trials where vitamin D was used as a preventative for catching the flu or common cold.
A study published in the American Journal of Clinical Nutrition provided schoolchildren with either 1200 IU/d of vitamin D or with a placebo for one winter period (December till March) and found that the children who received the vitamin D supplement were more than 40% less likely to become sick of the flu. 
Another study supplemented with only 300 IU/d vitamin D and found that compared to the control, the children who received the vitamin D supplement experienced 50% fewer respiratory infections. 
On the other hand, another study found no difference in respiratory tract infections in healthy adults when one high dose of vitamin D was received once a month. 
For the potential mechanism behind it; Research has shown that vitamin D plays an important part in the antimicrobial defenses. When immune cells recognize pathogens (TLR) they increase the expression of Vitamin D receptors, which results in the production of antimicrobial peptides.  In fact, scientist found that the production of some anti-microbial peptides (Cathelicidin) depends entirely on the activation of the vitamin D receptor. 
Vitamin D seems to not only support the immune system to fight off infections but helps to dampen it whenever it is not needed. This can be extremely important for people with autoimmune diseases.
Observational studies frequently link vitamin D deficiency to autoimmune diseases including multiple sclerosis (MS), rheumatoid arthritis (RA), diabetes mellitus (DM) and inflammatory bowel disease (IBD). [16, 17]
For instance, a connection between MS and vitamin D comes from associations between MS frequency and latitude. Gernally, people living further away from the equator have an increased risk to develop autoimmune diseases, potentially due to a lack of sun. 
However, most clinical trials with vitamin D supplementation show some improvement of the autoimmune disease but often fail to reach statistical significance, meaning that it is unclear whether vitamin D supplementation can be used as a treatment for autoimmune diseases. 
Having said this, vitamin D supplementation seems to be the most efficient in autoimmune diseases directly involving the gut but we will come back to this later.
Seasonal affective disorder (SAD) is a mood disorder in which people who have normal mental health throughout most of the year exhibit depressive symptoms at the same time each year, most commonly in winter. Common symptoms include sleeping too much, having little to no energy, and overeating.
Vitamin D deficiency is associated with low mood  and clinical trials show that vitamin D supplementation improves mood in healthy subjects, as well as in subjects that already suffer from symptoms of depression. [20, 21]
Brain / Cognitive performance
There has also been claims that vitamin D supports longevity. However, the effect of vitamin D supplementation on mortality is not clear, with one meta-analysis finding a small decrease in mortality in elderly people. 
However, it is important to point out that bone fractures (including hip fractures) are a huge factor for mortality in elderly and considering that vitamin D supplementation increases bone strength and reduces the frequency of bone fractures, it is likely that this by itself can increase the life-span.
One important concept of gut health is the integrity of the intestinal barrier. A leaky gut - that is a permeable gut cell wall - is associated with many diseases, including autoimmune and neurodegenerative diseases.
Researchers now think that there is a link between vitamin D deficiency and inflammatory bowel diseases and a study published in 2014 shows that vitamin D supplementation improves inflammation status and stabilizes intestinal permeability in patients with Crohn’s diseases. [23, 24]
Another study in mice found that the vitamin D receptor is critical for the intestinal mucosal layer, a protective layer on top of the cells lining the gut that prevents direct contact of the gut bacteria with the gut-resident immune system. 
Risk Factors for Vitamin D deficiency:
Dark skin: Melanin reduces the absorption of UVB radiation and therefore, prevents the ability to produce vitamin D
Age: As we age our body becomes less efficient at producing vitamin D from sun exposure. In fact, a 70-year-old makes 4 times less vitamin D from the sun than a 20-year-old. 
Body fat percentage: A higher concentration of body fat prevents the vitamin D from being released into the blood stream. In fact, obese individuals have 50% less bioavailability of vitamin D compared to non-obese individuals. 
Vegan/Vegetarian Diets: Animal and fish food sources are relatively high in vitamin D and a study found that people who follow vegan and vegetarian diets have lower levels of vitamin D.
Dietary sources of Vitamin D
Cod Liver Oil: 450 IU per teaspoon (4,9ml)
Herring: 1,600 IU per 3.5-ounce (100g)
Sardines: 200 IU per 3.5-ounce
Wild-caught salmon: 1000 IU per 3.5-ounce
Farmed salmon: 250 IU per 3,5-ounce
Oyster: 320 IU per 3,5-ounce
Shrimp: 150 IU per 3,5-ounce
Eggs (from pasture-raised chicken): 100 IU per egg
Eggs (from indoor-raised chicken): 25 IU per egg
Wild Mushrooms: Can contain up to 2,300 IU per 3,5-ounce
UV-treated mushrooms: 130-450 IU per 3,5-ounce
1µg vitamin D equals 40 IU
Daily RDI 600 IU or 1,5µg
Kongsbak et al., The Vitamin D receptor and T Cell function, Front Immunol, 2013
Forrest et al., Prevalence and correlates of vitamin D deficiency in US adults, Nutr Res, 2011
Levis et al., Vitamin d deficiency and seasonal variation in an adult South Florida population., J Clin Endocrinol Metab. 2005
Richard et al., Prevalence of Vitamin D Deficiency and Its Associations with Skin Color in Pregnant Women in the First Trimester in a Sample from Switzerland, Nutrients, 2017
MacLaughlin, J. & Holick, M. F. Aging decreases the capacity of human skin to produce vitamin D3. The Journal of clinical investigation, 1985
Wortsman, J., Matsuoka, L. Y., Chen, T. C., Lu, Z. & Holick, M. F. Decreased bioavailability of vitamin D in obesity. The American journal of clinical nutrition, 2000
Bischoff-Ferrari et al., Fall prevention with supplemental and active forms of vitamin D: a meta-analysis of randomised controlled trials, BMJ. 2009
Broe, K. E., Chen, T. C., Weinberg, J., Bischoff-Ferrari, H. A., Holick, M. F., & Kiel, D. P. (2007). A Higher Dose of Vitamin D Reduces the Risk of Falls in Nursing Home Residents: A Randomized, Multiple-Dose Study. Journal of the American Geriatrics Society
Henschkowski, J. (2009). Prevention of Nonvertebral Fractures With Oral Vitamin D and Dose Dependency. Archives of Internal Medicine
Ginde AA, Mansbach JM, Camargo CA Jr. Association between serum 25-hydroxyvitamin D level and upper respiratory tract infection in the Third National Health and Nutrition Examination Survey. Arch Intern Med. 2009
Urashima M, et al. Randomized trial of vitamin D supplementation to prevent seasonal influenza A in schoolchildren . Am J Clin Nutr. (2010)
Camargo CA Jr1, et al. Randomized trial of vitamin D supplementation and risk of acute respiratory infection in Mongolia . Pediatrics. (2012)
Murdoch DR1, et al. Effect of vitamin D3 supplementation on upper respiratory tract infections in healthy adults: the VIDARIS randomized controlled trial . JAMA. (2012)
Liu PT, et al. Toll-like receptor triggering of a vitamin D-mediated human antimicrobial response. Science. 2006
Hata et al., Administration of oral vitamin D induces cathelicidin production in atopic individuals, J Allergy Clin Immunol, 2008
Adorini L. Intervention in autoimmunity: the potential of vitamin D receptor agonists. Cell Immunol. 2005
Dankers et al., Vitamin D in Autoimmunity: Molecular Mechanisms and Therapeutic Potential, Front Immunol, 2016
Simpson S Jr, et al. Latitude is significantly associated with the prevalence of multiple sclerosis: a meta-analysis . J Neurol Neurosurg Psychiatry, 2011
Wilkins et al., Vitamin D deficiency is associated with low mood and worse cognitive performance in older adults, Am J Geratr Psychiatry, 2006
Lansdowne et al., Vitamin D3 enhances mood in healthy subjects during winter, Psychopharmacology (Berl). 1998
Jorde et al., Effects of vitamin D supplementation on symptoms of depression in overweight and obese subjects: randomized double blind trial, Journal of Internal Medicine, 2008
Bjelakovic G, "Vitamin D supplementation for prevention of mortality in adults". The Cochrane Database of Systematic Reviews, 2014
Lim et al., Mechanisms of disease: vitamin D and inflammatory bowel disease., Nat Clin Pract Gastroenterol Hepatol, 2005
Raftery et al., Effects of vitamin D supplementation on intestinal permeability, cathelicidin and diseases markers in Crohn’s diseaes: Results from a randomized double-blind placebo-controlled study, United European Gastroenterology Journal 2015
Kong et al., Novel role of the vitamin D receptor in maintaining the integrity of the intestinal mucosal barrier, Am J Physiol Gastrointest Liver Physiol, 2008