The immune microenvironment plays a vital role in the progression of hepatocellular carcinoma (HCC). Thousands of immune-related genes (IRGs) have been identified, but their effects on HCC are not fully understood. In this study, we identified the differentially expressed IRGs and analyzed their functions in HCC in a systematic way. Furthermore, we constructed a diagnostic and a prognostic model using multiple statistical methods, and both models had good distinguishing performance, which we verified in several independent datasets. This diagnostic model was also adaptable to proteomic data. The combination of a prognostic risk model and classic clinical staging can effectively distinguish patients in high- and low-risk groups. Furthermore, we systematically explore the differences in the immune microenvironment between the high-risk group and the low-risk group to help clinical decision-making. In summary, we systematically analyzed immune-related genes in HCC, explored their functions, constructed a diagnostic and a prognostic model and investigated potential therapeutic schedules in high-risk patients. The model performance was verified in multiple databases. Our findings can provide directions for future research.