Maintaining a healthy lifestyle is crucial for optimal immune function. This includes eating a balanced diet, engaging in regular physical activity, managing stress, getting sufficient sleep, practicing good hygiene, and receiving recommended vaccinations.