In Old English the past tense of “can” did not have an “l” in it, but “should” and “would” (as past tenses of “shall” and “will”) did. The “l” was stuck into “could” in the 15th century on analogy with the other two.
From Arika Okrent, in a MentalFloss piece about the weird history of some spellings. The piece has other examples of spelling changes to conform words to some aesthetic or another, even when those changes were inconsistent with the history and etymology of the word. And here’s a reminder to myself about the author’s book on invented languages.