Herd immunity occurs when a significant portion of a population becomes immune to a disease, reducing its spread and providing indirect protection to those who are not immune. Achieving herd immunity can be through natural infection or vaccination, but the threshold varies depending on the disease's contagiousness.