I've heard of the hypothesis it was a fungus infecting the wheat. I don't know what it's called in English, it's Mutterkorn in German. Concidentally (or not?) the precursor substance of LSD is produced by this fungus.
> One of the most prominent theories is that victims suffered from ergot poisoning, which was known as St. Anthony's fire in the Middle Ages. During floods and damp periods, ergots were able to grow and affect rye and other crops. Ergotism can cause hallucinations and convulsions, but cannot account for the other strange behaviour most commonly identified with dancing mania. [1]
> One of the most prominent theories is that victims suffered from ergot poisoning, which was known as St. Anthony's fire in the Middle Ages. During floods and damp periods, ergots were able to grow and affect rye and other crops. Ergotism can cause hallucinations and convulsions, but cannot account for the other strange behaviour most commonly identified with dancing mania. [1]
[1] https://en.wikipedia.org/wiki/Dancing_mania