A skeleton in the closet
A secret source of shame, potentially ruinous if exposed, which a person or family makes efforts to conceal.
The phrase 'a skeleton in the closet' was coined in England in the 19th century. Since then the word 'closet' has become used primarily in England to mean 'water closet', that is, lavatory - a possible hiding place for a skeleton I suppose, but not one with much potential. The English now usually use 'a skeleton in the cupboard', with 'skeleton in the closet' more common in the USA.
'A skeleton in the closet' undoubtedly originated as an allusion to an apparently irreproachable person or family having a guilty secret waiting to be uncovered. The close-at-hand domestic imagery of a closet or cupboard gives a sense of the ever-present risk of discovery. What isn't clear is whether the origin of the phrase lies in fiction or with real life, so to speak, skeletons.
The phrase was first used in the early 1800s. The first reference I can find in print is a figurative one in a piece by William Hendry Stowell, in the UK monthly periodical The Eclectic Review, 1816. The 'skeleton' in this case was disease, infectious or hereditary:
Two great sources of distress are the danger of contagion and the apprehension of hereditary diseases. The dread of being the cause of misery to posterity has prevailed over men to conceal the skeleton in the closet...
The dramatic device of a hidden body was used widely in the Gothic novels of the Victorian period. Edgar Allen Poe was the master of such tales; for example, this extract from The Black Cat, 1845 :
"Gentlemen, I delight to have allayed your suspicions", and here, through the mere frenzy of bravado, I rapped heavily upon that very portion of the brick-work behind which stood the corpse of the wife of my bosom. The wall fell bodily. The corpse, already greatly decayed, stood erect before the eyes of the spectators.
It has been suggested that the phrase derives from the era of the notorious body snatchers; that is, prior to 1832, when the UK's Anatomy Act allowed the more extensive use of corpses for medical research. The theory goes that, in a scenario similar to that of the concealment of Catholic priests in priest holes in domestic houses in Elizabethan England, doctors would conceal in cupboards the illegally held skeletons they used for teaching. There's no evidence at all to corroborate that theory. Concealed skeletons are occasionally found in walled-up in houses but they are usually those of unwanted infants.
The notion of a 'skeleton in the closet' as shorthand for the grim evidence of a murder was widely adopted into the language thanks to the writings of the popular Victorian author William Makepeace Thackeray. He referred to 'a skeleton in every house' in a piece in 1845 and explicitly to 'skeletons in closets' in The Newcomes; memoirs of a most respectable family, 1854–55:
Some particulars regarding the Newcome family, which will show us that they have a skeleton or two in their closets, as well as their neighbours.
Whether Thackeray was alluding to actual skeletons or whether he was responding to the imagination of authors like Poe, we are never likely to know. One person he certainly wasn't referring to was the 18th/19th century philosopher Jeremy Bentham, despite his being the best-known actual skeleton in a cupboard. Bentham was hardly aiming to keep his skeleton a secret as he willed that his body be preserved in a wooden cabinet. It is on public display in University College, London.
The American expressions 'come out of the closet' and simply 'come out' began to be used in the 1960s and are, of course, direct follow-ons from 'a skeleton in the closet'. As far as I'm aware, no one in the UK has declared themselves as gay by coming out of a cupboard.