Mad Hatters were truly "mad" -- as the result of erethism, a form of mercury poisoning.
English hat-makers used to use mercury during the process of felting a hat's wool. Sufferers of erethism -- or, erethism mercurialis -- suffered such symptoms as shyness and social phobia. In a sense, they went "mad."
However, Alice In Wonderland author Lewis Carroll did not base the character The Mad Hatter on a person suffering from the ailment. Instead, it is believed Carroll's inspiration for the Hatter was Theophilus Carter, an eccentric furniture dealer and inventor.