The study of the immune system, its components, and their roles in defending the body against pathogens.