Last week, I stated that vaccination generally doesn't play a role in medieval fantasy. A few days later, a reader quite rightly emailed me to call me out on that statement, which was something of an oversimplification. In deference to that reader, let's take a few moments to look at the history of vaccination and how it might figure into your campaign.
In very simple terms, vaccination is the process of taking a relatively safe sample of something dangerous, such as the cells of killed or weakened ("attenuated") bacteria or virus, or a toxin that they produce, and giving it to the body. The administered sample theoretically lacks the ability to cause a full infection or severe symptoms, but is none-the-less recognized as foreign by the immune system and therefore triggers the development of antibodies which remain in the body for the rest of its life. The actual agent in the vaccine is mostly safe; I say "mostly" because many vaccines use weakened but still living and potentially infectious organisms, and these can cause a full infection in people with weakened immune systems. The controversy around vaccines in the modern media centers mostly, not around the infectious agents in vaccines, but the additives and preservatives in them, perhaps most notably the infamous thiomersal/thimerosal compound. For the average person, it's enough to know that if you give a very weak form of something infectious, the body has the chance to learn how to fight it off, with a much lower risk of developing the full illness while it does so. Vaccines can only prevent illness; they don't cure them once symptoms have developed.
Vaccination, or more properly, its historical precursor of inoculation, is thought to go back at least a thousand years. Vaccination and inoculation aren't precisely the same thing. Inoculation classically refers only to a treatment to prevent smallpox, and involved exposing an individual to low doses of smallpox virus which weren't always as weak as one would hope. As with so many medical innovations, Chinese and Indian healers were using inoculation to save the lives of their patients while Europeans were still drinking holy water out of human skulls. Even with its staggeringly high complication/mortality rate of somewhere between 2-5% -- or, for our purposes, roughly the odds of rolling a natural 1 on a Fortitude or Constitution save -- inoculation was arguably one of the most astonishingly successful medical procedures of that era and one of history's earliest examples of empirically-based medicine. Understandably, when inoculation was introduced in Europe around the 1700's, many people balked at the idea of having deadly bacteria put into their bodies and there was massive resistance to it; England largely embraced it, but American physicians decried it as lunacy and in France it was, for a time, outlawed. Vaccination first came along as the 1700's became the 1800's and replaced inoculation by virtue of being safer and, until Andrew Wakefield and Jenny McCarthy, less scary. All of this is to say that it's by no means impossible that healers and alchemists in a medieval setting might have access to some form of inoculation or vaccination, either to smallpox or to any other infectious illness.
In a fantasy setting, there's no shortage of illnesses that might prompt the quest to find a preventative vaccine. I don't think I've ever seen a storyteller use smallpox in their campaigns, so this might not be one that grabs our attention as much as history tells us it should. Instead, let's consider one of the most important transmissible illnesses of fantasy: lycanthropy. Because no major rules system has ever elucidated the pathophysiology of the infection, we can't rightly say whether lycanthropy is a viral illness, bacterial illness, or something else entirely, but it's unquestionably one of the most feared infections if any fantasy setting, and that makes it a prime candidate for something that adventurers might want to be able to protect themselves from. The precise workings of a "werewolf vaccine" are left up to a storyteller's imagination, but because samples of the infectious agent are needed -- the saliva of a live and infectious werewolf, for example -- then manufacturing even a single dose of vaccine may be a quest in and of itself.
Alternately, if no such vaccine exists yet, the quest to invent it could become the focus for an entire storyline. A healer in the PCs' kingdom has heard stories of how some foreign people uses inoculation to prevent smallpox, and believes he can come up with something similar against lycanthropy. He hires the PCs to help him with his work, which might first involve acquiring texts from the foreign nation in question, then acquiring samples of rare plants and herbs required for the recipe, and finally perhaps capturing a live lycanthrope from which to derive the vaccine. Then, how does one weaken the infectious agent so that it's safe to administer? Is it as easy and mixing in a bit of wolfsbane? Or to weaken a magical disease, is the vaccine only safe when administered in an anti-magic field? There are countless wonderful points at which the PCs' plans can go terribly awry, from getting lost in foreign lands to the herbs they need being in contested territory between two orc tribes to the consequences of spreading an ineffective batch of vaccine in their home city and accidentally infecting thousands of innocent people with lycanthropy (or perhaps temporary lycanthropy, since the vaccine contained weakened infectious agent).
The pedant in me is forced to suggest that lycanthropy might be a poor choice for a vaccine because, in most rules systems, being infected with and then cured of lycanthropy doesn't usually protect a person from re-infection, the way fighting off smallpox or measles makes a creature immune. Still, this could either be changed in a game, or else the twist at the end of a storyline could be that after all the trouble, the vaccine doesn't actually prevent reinfection. Either way, the story opportunities are endless.