“Tomfoolery” means playful or silly behavior. The Brewer’s Dictionary of Phrase and Fable defines “tomfool” as, “A clumsy, witless fool, fond of stupid practical jokes. Hence ‘tomfoolery.'”
“Tomfoolery” is also the Cockney rhyming slang for jewelry. Like most rhyming slang it then gets shortened to Tom. For example: “That’s a nice bit of old tom she’s got round her neck.” However, also shortened to tom is another more basic piece of Cockney rhyming slang, a “tom tit,” meaning a bowel movement. You can translate those last two words into the appropriate slang word for yourself.
Tom Fool starts appearing in the historical record early in the 1300s in the Latinate form Thomas fatuus. The name “Thomas” was used as a generic term for an ordinary person, much the same way as we use the phrase “Tom, Dick or Harry.” Fatuus is the Latin word for stupid or foolish and from it has come “fatuous” and “infatuate,” among others.
The Morris Dictionary of Word and Phrase Origins tells us that back in medieval times it was considered great sport to watch the antics of insane people in asylums like Bedlam in London. The nicknames “Tom o’ Bedlam” and “Tom Fool” were often used for male inmates who were favorites of the audience.
And the Oxford English Dictionary’s entry for “Tom-fool” is: “As quasi-proper name, ‘Tom Fool’: a man mentally deficient; a half-witted person. Obsolescent.”
In King Lear, Shakespeare gave the name “Tom” to Edgar, in disguise and apparently living in a hovel as a madman.
Around the 1600s, the character of Tom Fool shifted from being a stupid or half-witted person to that of a fool or buffoon. He became a character who accompanied morris-dancers or formed part of the cast of various British mummers’ plays performed at Christmas, Easter or All Souls’ Day.
Tomfoolery seems a little more pronounced than foolery, the state of acting foolishly. I get the sense of the meaning now as being deliberately funny rather than just silly.
One of those what-to-name-your-baby books gives the meaning of Thomas as “twin.” No connection, is there? Unless you want to imagine that twin Toms can produce twice as much foolery.