The story
From the former euphemism do one's ease (“ease one's bowels: defecate”) and to distinguish the sense from other uses of closet (“a small, private room and [obs.] a small, private outdoor space”).
Etymology from Wiktionary, CC BY-SA 4.0.
Today it means: A room used to ease one's bowels: a lavatory. Full definition →