The primary function of the immune system is to act as a protectio­n mechanism against millions of bacteria, microbes, viruses, toxins, and parasites that might try to invade your body.