When the immune system first seen an infections microbe, it responds against this and then remembers it specifically. The next time when that particular microbe or its close relatives enter the body, the immune system responds more vigorously. This eliminates the infection more quickly than the first time around. This is the principle of immunisation.