Rigmarole sounds like a word invented for its own sound. It is actually a worn-down medieval term that survived for about 450 years before reaching its modern form.

The ancestor is ragman roll. Merriam-Webster traces it to a medieval game played with a roll of verses, each describing a character. The name combines Anglo-French Ragemon le bon, the title character of the verses, with Middle English rolle. World Wide Words says the origin of the name is obscure and offers rag, in the sense of tatters, used as a name for a devil, as one possibility. Etymonline says the early word could also mean a document recording accusations, and it notes a possible link to an Old Norse word for a slanderer. Scholars have not settled which of these is right.

The word then landed on paperwork. World Wide Words says the name was transferred to various English statutes at the end of the thirteenth century. Wikipedia, citing a manuscript-terms dictionary, adds that "ragman" was used for documents with many pendent seals. The famous example is the Ragman Rolls, records of Scottish nobles and gentry swearing allegiance to Edward I of England. Wikipedia dates them to 1291 to 1292 and again to 1296. It also warns that accounts of how those rolls got the name are mixed and conflicting. Brewer's says the name first meant a statute, and Merriam-Webster points to the game, so the usual tidy story is only one possibility.

By about 1500 a ragman roll could mean any long list or catalogue. It then appears to have survived in Kent speech, and Etymonline suggests the modern word is an altered version of that survival. World Wide Words says the spelling riggmon-rowle turned up in the eighteenth century, and the form settled into "rigmarole." Etymonline gives 1736 for its first record, with the sense of a long, rambling discourse.

The meaning has drifted twice. It went from a catalogue to incoherent talk, then to a lengthy, tedious procedure. That final sense is the one in "the whole rigmarole of getting a visa." Etymonline dates the broader meaning of a foolish activity or commotion to 1939.

The link back to the medieval rolls has largely been lost, as World Wide Words notes. Few people who complain about a rigmarole know they are naming a parchment.