Vaccines basically insert an inactive "germ" in to our organism, this being creates a response in the human body by antibodies that connect with these antigens.
However this reaction is of lesser strength than an active being( in many cases). This reaction will create T memory cells that will know in a new exposition to the malady in question how to react and better destroy it.
Some ilnesses attack our immune system so in most cases we are harmless against said diseases unless we have been vaccinated, which implies that a vaccine to that malady exists.
When the Black Death attacked Europe, and being this disease one that attacks the immune system (i think) it killed around at least 25 million people through some time, but some people survived wich means if black death attacks again some people will survive