Herd immunity works by protecting the population from a virus or bacteria. When a large percentage of the population has developed a resistence to the virus either by vaccination or previous infections, the population as a whole is protected.