The story
Old English wrote night as niht, and the H was not silent. It stood for a breathy, scraping sound made at the roof of the mouth — close to the ch in German nicht, or a softer version of the ch in Scottish loch. German still has it in Nacht, Dutch in nacht, and Scots in nicht: all the same word.
In Middle English, scribes began writing that sound with gh — nyght, night — and sometimes with the old letter yogh (niȝt). The spelling recorded a real consonant: something like nikht.
Then the sound faded. In later Middle English and early Modern English, the GH sound disappeared from most dialects of English. When it went, the vowel before it changed too, and the short i of niht ended up as the long "ee" that the Great Vowel Shift then turned into "eye". That is how nikht became NITE.
By then the spelling night was established, and printers kept it. So the GH is a fossil of a sound English speakers really made, and it is why night and knight — once two quite different-sounding words — are now perfect homophones.
