The phrase has its roots in medicine, and was used to describe contagious and irritating long-term skin problems.
Not just skin, but the term was often used when referring to any prolonged condition.
It was first used to describe the point in a marriage where men are most likely to cheat in 1952, in the play of the same name by George Axelrod which was later turned into a film.