Studies suggest that deficiency of vitamins B and D can be linked to a weaker immunity (and a low white blood cell count) (20), (21). Hence, consuming a diet (or supplements) rich in these vitamins can boost your immune function. Consult a doctor for more information on the right diet and supplements.