MHC molecules function by presenting peptide antigens to T cells. MHC Class I molecules present endogenous antigens (e.g., viral proteins) to CD8+ cytotoxic T cells, while MHC Class II molecules present exogenous antigens (e.g., bacterial proteins) to CD4+ helper T cells. This antigen presentation is critical for the immune system to recognize and respond to pathogens.