Diabetic retinopathy (DR) is the most common microvascular complication in diabetic patients, and recent studies have shown that immune regulatory mechanisms are closely associated with retinal damage in DR. Therefore, this study focused on exploring immune cells and immune-related genes (IRGs) in DR and gaining insight into the ceRNA mechanisms by which IRGs regulate DR progression. Four datasets from human DR model retinal tissues were obtained from the Gene Expression Omnibus (GEO) database. R software was first used to identify differentially expressed mRNAs (DE-mRNAs) in the dataset GSE160306-mRNAs, then the distribution of immune cells in the gene matrix was analyzed by xCell and ImmuCellAI, ImmPort and InnateDB database were used to obtain immune-related hub genes (IRHGs) in the DR, and finally the STRING online tool and Cytoscape to construct the immune-related ceRNA network. The datasets GSE102485, GSE160308 and GSE160306-lncRNAs were used to validate the results of the ceRNA network further. The results of immune cell infiltration analysis showed that macrophages are important immune cells in DR; immune-related gene screening showed that FCGR2B is an IRHG in DR, and 2 immune-related ceRNA networks of IRHG were obtained: DDN-AS1/miR-10a-5p/FCGR2B and LINC01515/miR-10a-5p/FCGR2B. Our study suggests that infiltration of immune cells, especially the immune role of macrophages, is an important component of DR progression; the immune-related hub gene FCGR2B and its ceRNA network may be a key regulatory network for DR progression. The discovery of key immune cells, IRHG and ceRNA networks in this study may provide new prospects for early intervention and targeted treatment of DR.