Diet has long been considered a risk factor related to an increased risk of cancer. This challenges us to understand the relationship between the immune system and diet when abnormal cells appear in a tissue. In this paper, we propose and analyze a model from the point of view of a person who follows a healthy diet, i.e., one correlated to the food pyramid, and a person who follows an unhealthy diet. Normal cells and immune cells are used in the design of the model, which aims to describe how the immune system functions when abnormal cells appear in a tissue. The results show that the immune system is able to inhibit and eliminate abnormal cells through the three following stages: the response stage, the interaction stage, and the recovery stage. Specifically, the failure of the immune system to accomplish the interaction stage occurs when a person follows an unhealthy diet. According to the analysis and simulation of our model, we can deduce that dietary pattern has a significant impact on the functioning of the immune system.