In the context of the global pandemic, enhancing immunity is an important way to defeat the virus. This article analyzes the immune system and immune function of the body and proposes to intervene in the function of the immune system through diet and various intensities of exercise. Research has shown that doing less intensive exercise can improve the impact of negative emotions, thereby enhancing the immune system. Long-term high-intensity exercise can suppress immune function. In the event of a disease outbreak, the immune system can be strengthened by providing adequate nutrition. The most important thing is that the human body should have sufficient high-quality protein. Firstly, protein is the material foundation for maintaining health. Secondly, the human body needs to consume more vitamin A. Thirdly, we mainly eat trace elements such as iron, zinc, and selenium. Fourthly, there must be more biologically active foods. At the same time, it is important to ensure sufficient sleep, a good mood, and exercise.