The ancient conjugation of the imparfait used "oi" instead of "ai". So, we said, "je mangeois, tu mangeois, il mangeoit...". Moreover, "oi" was not pronouced "[oua]" as it is today, but "[ouè]".
It is said that once, Louis XVI's brother, who came back from a long exile in England to replace Napoleon after Waterloo and restore the ancient kingdom under the name of Louis XVIII (by mark of respect for the former king's son, who would have been Louis XVII if ever he had reigned) went angry because his ministers didn't want to accept one of his decisions. So, he said (suppose that "[rr]" means a rolled "r"):
"[Le rrouè, c'est mouè!]" (old phonetics for "Le roi, c'est moi!").
Then his counselor coldly told him : " Your majesty, nowadays, no one says "mouè" any more, so you should say: '[le roua, c'est moua] "...
By the way, the changing happened at the French revolution, when the "Incroyables" and the "Merveilleux" wanted to set their mark on the spoken language, so they replaced the old rolled "r" by the modern guttural "r", which happened to spread over Germany afterwards, and they changed the pronunciation of "oi" from "[ouè]" to "[oua]". It seems that the conjugational change from "oi" to "ai" took place by that time too, because in the texts from around 1750, "oi" is still fully used.
We can suppose that changing the conjugation from "oi" to "ai" happened for a phonetical reason, the will to simplify a diphtongue to a simple sound, since "oi" was a diphtongue ([ouè]) and so changing it to "ai" made the sound "[ou]" disappear, so it went from "[ouè]" to "[è]". In that hypothesis, the changing of "oi" to "ai" must have taken place some time before the phonetical change of pronunciation of "oi".