Not only does the immune system have to fight intruders but it must also take care not to damage its friends. As the teacher in the school for white blood cells says in the series Once Upon a Time… Life: “It is important that you know who to attack and never make a mistake.”
Anthills are fascinating. An ant colony is like a single organism, whose cells (individual ants) make up the organs (castes of ants), fulfilling different functions: defence, food supply, reproduction. Ants fiercely defend access to their colonies, knowing how valuable the resources inside are for other animals: defenceless larvae, the worker ants that feed them, and food stores. The latter, for some species of ant, such as the honeypot ant (Prenolepsis nitens), come in the form of living larders of defenceless worker ants, stuffed full with food right up to the holes in their chitin armour, stuck immobile in one place…
Worker ants, and in particular soldiers, recognize most of their intruders by smell and fight; but not all. For example, the larvae of a beautiful butterfly, the Scarce Large Blue, have learned to outsmart the ants, secreting pheromones similar to those of ant larvae. This guarantees them free food, (they are fed by the worker ants looking after their own larvae) and security (thanks to the very same defence system they were able to fool).
Each one of us, as multicellular organisms, is precisely such a colony. And the defenceless, specialized cells inside our bodies are a risk-worthy target for viruses, bacteria and all types of parasites.
The need to have a defence against other organisms and viruses is probably as