Vaccination is the process of using a small amount of disabled or harmless viruses or bacteria in order to encourage the body to produce antibodies to the infection. The next time the patient is exposed to the infection, the body rapidly produces antibodies to destroy the infection.
It has been known since ancient times that patients who survive a serious illness are never affected by that illness again. We now know that this is because the antibodies in the immune system take time to develop given an initial infection, but react rapidly when exposed to the identical infection later on.
In the 18th century, William Jenner noticed that people who had developed cowpox, a mild disease passed on to humans by cows, never developed smallpox, a very contagious disease with a very high mortality rate. He went about deliberately infecting patients with cowpox, and the infection rate for those patients fell dramatically compared to those who had not been exposed. Jenner's original concept was so sound that by the 20th century, smallpox had been extinguished in the wild. The last known infection was from a laboratory sample.
The techniques of producing vaccine have improved since Jenner's day, and now several once ubiquitous illnesses such as polio, measles and rabies have largely disappeared. However, some diseases resist vaccination. Influenza changes so quickly that patients have to be vaccinated every year against a new strain. There are so many strains of the common cold that vaccination is impossible. HIV has also resisted all attempts at vaccination.