It wasn't the solitude. The Old Salt Blog explains:
In the 19th century, lighthouse keepers had a high frequency of madness and suicide. Many assumed that they went mad from solitude and the demands of the job. It turns out it was something simpler and more sinister.For an exhaustive academic study of the subject, see Lighthouse Keeper's Madness: Folk Legend, or Something more Toxic? in the Proceedings of the 11th Annual History of Medicine Days at the University of Calgary.
Fresnel lenses were the great lighthouse innovation of the 19th century. The lenses developed by French physicist Augustin-Jean Fresnel greatly increased the intensity and range of the lighthouse beacon. For rotating lights, just as importance as the strength of the light, however, was maintaining a specific speed of rotation, so that if the chart said that the light flashed every twenty seconds, the light, in fact, rotated so that the light was visible every twenty seconds. The best near zero-friction bearing of the day was created by floating the light and the lens on a circular track of liquid mercury. When dust, dirt or other impurities built up in the mercury, part of the light house keeper’s job was to strain the mercury through a fine cloth.
The last operating lighthouse Fresnel lens in the United States is in the Split Rock Lighthouse near Two Harbors along Minnesota's famed North Shore of Lake Superior (top photo).
Their blog entry from 2009 describes the extreme precautions taken nowadays when the lens needs to be serviced:
Nearly two gallons of mercury was drained, and the mercury bowl and float cleaned, and the mercury replaced. The very small surface area of mercury that is exposed to the air when the float is closed was covered with mineral oil to stop any mercury exposure to the air.