The mythical connection between phases of the moon, madness and epilepsy are discussed in an engrossing but sadly locked article from the Journal of the History of the Neurosciences.
However, it does have this wonderful section where some of the more whimsical portrayals of ‘lunacy’ are discussed:
In the epic poem by Ludovico Ariosto, “Orlando Furioso” (1532/1992), when the paladin Orlando learns that his lover Angelica is married, he becomes mad and goes through Europe and Africa destroying everything in his path. The English knight Astolfo flies up to moon where all human intellects lost on Earth are collected and finds Orlando’s in a bottle, thus restoring him to sanity (Ariosto, 1532/1992).
In the seventeenth century, the term “lunatic,” especially in its more specific acceptation of “insane” as a result of some mental obsession, began to be substituted by the term “moonstruck.” Reflecting the popular association between the moon and the irrational, primitive, and dark side of the human mind, the adjective “moonstruck” makes its first appearance in John Milton’s Paradise Lost.
Link to summary and DOI entry for ‘lunacy’ article.