Instead of "rule", think "pattern." Spelling evolved, not to follow rules, but to create meaning for people who already know and speak the language.
Doubling is mainly lexical. That is, doubling generally occurs in the base of an English word. It is a way of adding stress to the base and/or preserving the quality of short vowels.
The general pattern is that the last letter of a base is doubled if:
a) the added suffix begins with a vowel
b) the base ends with a single consonant letter preceded by a single vowel letter.
c) the stress IN THE FINAL WORD is on the vowel immediately preceding the suffix.
Certain letters never double, like w (already is a double-u) and x (two phones).
re + fer + ed --> referred
the base is <fer> and doubles because <ed> is a vowel suffix, has the VC pattern, and the stress in the final word is on the <fer>.
re + fer + ence --> reference
the base is <fer> and does NOT double, even though it has a vowel suffix and <fer> has the VC pattern, because the stress in the final word is one the <re>.
As mentioned above, sometimes a "double" consonant is not actually doubled, it is just the same letter ending one morpheme as the beginning of the next.
mis + spell --> misspell
This is NOT a doubled <d>
When <-le> is acting as a suffix (it often does not) in English, it acts as a vowel suffix and forces doubling.
Vowel suffixes that begin with the letter <i> do not usually force doubling,
except <ing> which always does.