What is the function of the immune system

A. It exchanged oxygen and carbon dioxide.
B. It provides structure for the body.
C. It eliminates waste from the body.
D. It responds when pathogens enter the body.