When faced with a new pathogen, your immune system tries out different antibodies that will be successful in fighting it (new types of antibodies are created in a kind-of evolutionary process). Once a successful anti-body is created, your body is prepared to fight the next invasion of that pathogen. A vaccine contains either something similar to the germ or a 'dead' form of the virus so that your body has a chance to figure it out without having you actually get sick (i.e., many live germs will do you in before your immune system can figure out a defense).