What we commonly call "The Plague" aka, the Black Death of the 14th century only lasted a few years, but the disease itself continued to pop up and cause localized epidemics for centuries. Isaac Newton formulated his famous three laws of motion while in the countryside trying to avoid the Great Plague of London in the 1660s. An example of historical social distancing.
The Plague burned itself out because it killed its victims faster than the disease could spread, especially after the disease caused a collapse in trade. There is no "natural immunity" to plague, it was almost uniformally lethal before the discovery of antibiotics. What kept subsequent plagues as mere epidemics (as opposed to pandemics) were that people learned how to efficiently quarantine. The disease finally reverted back to an almost solely zooinotic infection because of the massive expenditures in public sanitation during the 1700-1800s. Making our filthy cities less filthy had multiple benefits in the fight against many different diseases. Which is why I actually worry about outbreaks of typhus, cholera, TB and even plague returning to certain west coast US cities if the present circumstance continues.
The lesson- plague didn't just go away because it ran its course. It became a very rare disease, even before we had antibiotics, because we learnes how to control it and we took the necessary steps.