I've been reading Chaucer's "The Knight's Tale" in Middle English. When I'm unsure of the meaning - often enough - I glance at the facing page for the Modern English version.
I was amused when I came across 2 different spellings of pain around line 461: peyne vs. pyne.
The spelling seems to change depending on what word it's being rhymed with.
Simplifying drastically, the rhymes are pain / complain, and pain / divine.
I don't know much about pronunciation back then. I'm guessing that there were 2 acceptable ways to pronounce "pain". Spelling wasn't standardized. So the spelling of a word changed to match the pronunciation.
I have to admit, I still do this once in a while. Usually with an apostrophe. Usually to indicate that I'm dropping the final "g" in a rhyme like this:
There was a high-schooler named Helen,
Who always won contests for spellin'.
She said: "Drop that G
In a real spelling bee,
And you'll be sent away as a felon."