Researchers at Brigham and Women's Hospital and Harvard Medical School ran a five-year trial of 25,871 adults, half given vitamin D supplements and half a placebo, to test that belief directly rather than through observational surveys.
Vitamin D supplementation did not significantly reduce the overall rate of invasive cancer or major cardiovascular events compared with placebo over the five years of the trial. A possible reduction in cancer death appeared only in an unplanned analysis that set aside the first two years, not in the trial's primary result.
The trial did not screen participants for deficiency. About 13 percent of those tested started with low vitamin D levels, and results did not differ by starting level. It used one fixed daily dose of 2,000 IU rather than adjusting for each person's blood level, and found no reduction in cancer or heart disease from supplementation.

Read the original study
Daily vitamin D, no detectable benefit.
Source
- Manson, J. E., Cook, N. R., Lee, I.-M., Christen, W., Bassuk, S. S., Mora, S., Gibson, H., Gordon, D., Copeland, T., D’Agostino, D., Friedenberg, G., Ridge, C., Bubes, V., Giovannucci, E. L., Willett, W. C., & Buring, J. E. (2019). Vitamin D Supplements and Prevention of Cancer and Cardiovascular Disease. New England Journal of Medicine, 380(1), 33–44. https://doi.org/10.1056/nejmoa1809944