Non-alcoholic fatty liver disease (NAFLD), which includes simple steatosis (SS) and non-alcoholic steatohepatitis (NASH), is a significant contributor to liver disease on a global scale. The change of immunity-related genes (IRGs) expression level leads to different immune infiltrations. However, the expression of IRGs and possible regulatory mechanisms involved in NAFLD remain unclear. The objective of our research is to investigate crucial genes linked to the development of NAFLD and the transition from SS to NASH. Dataset GSE89632, which includes healthy controls, SS patients, and NASH patients, was obtained using the GEO database. To examine the correlation between sets of genes and clinical characteristics, we employed weighted gene co-expression network analysis (WGCNA) and differential expression analysis. Hub genes were extracted using a network of protein-protein interactions (PPI) and three different machine learning algorithms. To validate the findings, another dataset that is publicly accessible and mice that were subjected to a high-fat diet (HFD) or MCD diet were utilized. Furthermore, the ESTIMATE algorithm and ssGSEA were employed to investigate the immune landscape in the normal versus SS group and SS versus NASH group, additionally, the relationship between immune infiltration and the expression of hub genes was also examined. A total of 28 immune related key genes were selected. Most of these genes expressed reverse patterns in the initial and progressive stages of NAFLD. GO and KEGG analyses showed that they were focused on the cytokine related pathways and immune cell activation and chemotaxis. After screening by various algorithms, we obtained two hub genes, including JUN and CCL20. Validation of these findings was confirmed by analyzing gene expression patterns in both the validation dataset and the mouse model. Ultimately, two hub genes were discovered to have a significant correlation with the infiltration of immune cells. We proposed that there were dynamic changes in the expression levels of IRGs in different stages of NAFLD disease, which led to different immune landscapes in SS and NASH. The findings of our research could serve as a guide for the accurate management of various phases of NAFLD.