Lunatic is one of the clearest records of an old belief: that the moon could change a person's mind.
The word is Late Latin lunaticus, built from luna, "moon," with an adjective ending. Etymonline says it reached English from Old French lunatique or straight from Latin, in the late 13th century. Merriam-Webster dates the first uses to the 14th century. Both describe the original sense the same way: affected by an illness that came and went with the changes of the moon.
Merriam-Webster adds a surprise. The Latin word is not found in classical Latin outside the legal writings of Julius Paulus, in the 2nd and 3rd centuries AD. It may have been modeled on fanaticus, "inspired by orgiastic rites," which has a similar ending.
Other languages built the same idea. Etymonline lists Old English monseoc, "moon-sick," and the New Testament Greek verb selēniazomai, "to be epileptic," from selēnē, "moon." In both cases the moon is blamed for a condition we no longer attribute to it.
In English law the word was precise. Etymonline notes that an "idiot" was someone without understanding from birth, while a "lunatic" was someone who lost it later, and that the noun first meant a person with lucid intervals. Over time it became a general term for a person of unsound mind. The Lunacy Act of 1845, which Lord Shaftesbury helped secure, used medical certification to separate those people from social outcasts. Today, the Oxford Companion to British History says, clinicians no longer use the word.
Meanwhile it spread into ordinary speech. Etymonline says Theodore Roosevelt popularized "lunatic fringe" in 1913 for extremists within a reform movement. He did not coin it. Phrase Finder traces it to 1870s slang for a fringe of hair cut over the forehead. It places Roosevelt's use in a December 1913 address to the American Historical Association, not an autobiography. Etymonline also records "lunatic soup" in 1918 as slang for strong drink.
The Latin root lives on elsewhere, too. Etymonline notes that luna was also an alchemical name for silver.