This review looks at the critical role of vitamin D in improving barrier function, production of antimicrobial peptides including cathelicidin and some defensins, and immune modulation. The function of vitamin D in the innate immune system and in the epithelial cells of the oral cavity, lung, gastrointestinal system, genito-urinary system, skin and surface of the eye is discussed. Clinical conditions are reviewed where vitamin D may play a role in the prevention of infections or where it may be used as primary or adjuvant treatment for viral, bacterial and fungal infections. Several conditions such as tuberculosis, psoriasis, eczema, Crohn's disease, chest infections, wound infections, influenza, urinary tract infections, eye infections and wound healing may benefit from adequate circulating 25(OH)D as substrate. Clinical diseases are presented in which optimization of 25(OH)D levels may benefit or cause harm according to present day knowledge. The safety of using larger doses of vitamin D in various clinical settings is discussed.