Cowpox was the original vaccine of sorts for smallpox. After infection with the disease, the body (usually) gains the ability recognise the similar smallpox virus from its antigens and so is able to fight the smallpox disease much more efficiently.