The expression “mad as a hatter” doesn’t mean irate, a sense one sometimes hears; it means crazy, utterly demented.
There have been various theories advanced for this peculiar metaphor, and some of the theories are themselves peculiar.
One is that “hatter” was introduced merely to add an intensive force, that the individual spoken of was just more “mad” than would be ordinarily expected under the circumstances.
Another is that the original comparison was “mad as an adder,” under the assumption, I suppose, that adders are always insane.
But an explanation that I like was that given in an issue (Vol. 155, No. 3) of The Journal of the American Medical Association:
“It seems that mercury is used in the making of felt hats. Often the unfortunate hatter who would work for years with the mercury would be afflicted with a violent and uncontrollable twitching of his muscles as a result of its poisoning effects. His friends, not understanding the cause of his strange gyrations, concluded that he was mad.”
Lewis Carroll’s character, “The Mad Hatter,” in Alice in Wonderland (1865) was derived from the expression, but it was in use by Thomas Haliburton in 1837 in The Clockmaker, and because mercury was used in hat-making much earlier than that, it may have already been in the argot of hatters long previously.