The Hatter had a Mad Tea-Party, and became the Mad Hatter in the public imagination.
The phrase “mad as a hatter” first appeared in the 1830s, a few decades before ‘Alice’s Adventures in Wonderland’ was published, and was used to describe the tremors and mental deterioration of English and French hatters exposed to mercury in the process of making felt.
Lewis Carroll was the pen name of Charles Lutwidge Dodgson. His uncle, Robert Wilfred Skeffington Lutwidge, held a rather bizarre title, and one you’ve probably never seen or heard of: Commissioner of Lunacy. That meant he was responsible for inspecting England’s lunatic asylums. Since Dodgson (Carroll) maintained a close relationship with his uncle, he saw for himself what went on in the Victorian institutions.
The Mad Tea-Party in ‘Alice’s Adventures in Wonderland’ was directly inspired by tea parties he witnessed as forms of social therapy in the asylums.