A vaccine is a biologic medication which can be injected in order to stimulate the body's immune system into recognizing and destroying an infectious agent, such as a particular type of virus. Vaccines are now a regular and essential way of preventing a wide range of once-serious infections, ranging from rabies to smallpox. In most cases, vaccines are strictly preventative - that is, they are only effective if they are administered before exposure to the virus occurs. However, other vaccines, such as the vaccine which protects against rabies, can be used at any time, after as well as prior to exposure.
Vaccines were discovered in the 1790s by Edward Jenner as a way of combatting what was then the most serious endemic disease in the Western world: smallpox. Smallpox took a regular toll on European children, but its destructive path through North America is much better known to the public today - a wave of epidemics which wiped out as much as 90% of many Native American societies. Edward Jenner's smallpox "vaccine" was actually another similar virus, cowpox. Jenner realized that people exposed to cowpox inexplicably became immune to smallpox - and therefore, in essence, set about infecting as many people with cowpox as he could.
It took over a century of biological and genetic research to understand what Jenner had discovered, but in the meantime new vaccines were developed. What he had stumbled upon in the barn was, in essence, how the immune system works: first by recognizing a particular type of invader as a threat, and then responding to that threat whenever it is recognized again in the future. (That is, the immune system "remembers" threats encountered in the past, and responds actively to them if it encounters them again in the future.) Cowpox was different enough from smallpox that it did not cause serious illness in humans - but it was similar enough that the human system could not tell the difference between the two. As a result, once the immune system had responded once to cowpox, in the future it could quickly identify and eradicate any smallpox particles invading the body.
Today, the vaccine industry is very large and uses a variety of techniques to prepare its products, but the principle is essentially the same. Today, rather than other viruses entirely, vaccines are usually copies of the virus in question, which have either been killed off or have been specifically manipulated in such a way that they are "inactive" - that is, alive, but incapable of infecting cells and reproducing. These are known as "live attenuated" vaccines. Still other vaccines consist of toxins secreted by the virus - in which case the immune system activates not by sensing the pathogens, but by sensing the toxins and then targeting the pathogens. In any case, the particles in the vaccine have been crippled in such a way that they are not a threat, but still resemble the original virus enough that the immune system will see them as one and the same. This way, the immune system is essentially given the chance to "test" itself against the killed or crippled virus in the vaccine, so that it will be able to respond immediately to a real infection in the future.
Like many inventors, Jenner had no idea of the significance of what he had discovered. Today, however, vaccines are not simply used against smallpox (which they have been used to eradicate entirely), but the flu, polio, rabies, measles, and many other diseases. Thanks to the artificial immunity given by vaccines, many formerly feared killers have been rendered largely ineffective.
At the same time, however, it is important to be fully aware of all of medical instructions regarding vaccines you may take. Some vaccines must be given on established schedules to infants and young children. Others are taken as adults - and some of these require re-vaccination on an occasional basis, to keep the immune system from losing the resistance it has gained. Many vaccines also have mild or serious side effects. Always discuss concerns or questions about particular vaccines with your doctor, who can offer professional medical advice tailored to your specific situation.