"long, tedious, complicated story," by 1905, from Yiddish Megillah (as in a gantse Megillah "a whole megillah"), literally "roll, scroll," collective name of the five Old Testament books appointed to be read on certain feast days, from Hebrew meghillah, from galal "he rolled, unfolded." The slang use is in reference to the length of the text. The use of the word in English in reference to the holy books is from 1650s.
Jonas used to laugh. "What do I care for the Goyim," he said, but Isaac was different. He would talk thee a Megillah about Equality and Brotherhood,—one would have thought, he was reading something aloud out of the newspaper,—and what he meant was that the Yüd and the Goy were now alike. [Martha Wolfenstein, "A Renegade," Philadelphia: Jewish Publication Society of America, 1905]