The immune system is a defense mechanism that acts to protect vertebrates against death and debilitation by infectious diseases. In the absence of an immune system even innocuous bacteria and viruses cause death. It turns out that the immune system arises rather late in evolution.
Bacteria suffer from viral infections, and have developed successful defense mechanisms.
There is a key distinction between aquatic and terrestrial life in that the uniformity of the aquatic environment is contrasted with the sharp discontinuities of the land where the watery ponds and lakes are far apart, where wind and rain, ice and snow, heat and drought are all found within the climates that a typical vertebrate can visit during a lifetime. The range of infectious diseases faced by a long lived vertebrate is huge. However, the most difficult task of defense comes when the rapidly evolving pathogen has the potential to escape the slowly evolving vertebrate defenses. Thus, the vertebrates can only grow big slowly, and reproduce slowly, and unless they develop a means of defense that permits a rapid evolutionary adaptation, the pathogens will stall their development. The immune system is a defense mechanism that can evolve during the lifetime of the individual and as such is the only system other than the brain that can undergo somatic evolution.