It’s very simple, ‘refrigerator’ is spelt like that because it’s from Latin.
The word is long so people wanted to shorten it, they took the sound /fɹɪdʒ/ from the middle of the word and said that as an abbreviation. Now when deciding on how to spell it they decided to spell it phonetically according to the rules of normal English spelling where if the j-sound is at the end of a word after a short vowel it is most often spelt -dge, so it gets spelt phonetically as ‘fridge’
If it weren’t spelt phonetically it would’ve been spelt maybe as ‘frige’ which could’ve still worked because English spelling is so flexible, but it also is a little more ambiguous as to the pronunciation, so the phonetic respelling works best, and that’s why there’s a d in it.