I don’t know the story behind those words in particular…
In general spelling in the English language is a travesty of phonetic inconsistency because it wasn’t established by English speakers. Prior to the printed word the concept of universal spelling didn’t exist. Shakespeare spelled his name five different ways and even long after the arrival of the printing press Mark Twain declared,
“I don’t give a damn for a man that can only spell a word one way.”
The idea of universal spelling arrived with the revolution of printing technology. The thing is printing was being developed in non-English speaking countries like Germany and Belgium. This means Germans and Belgians that didn’t really know much about English spelling were trying to sort out how to write the English texts they were printing. For the most part they used the phonetic rules of their own language to transcribe English words.
The result was that some words became accepted with a German phonetic spelling while others, like “ghost”, follow the Dutch spelling. The result is an uncontrolled mishmash of unrelated phonetic systems and the only language with spelling so counter intuitive we have spelling competitions.
Some English words are actually foreign words and maintain their foreign spelling. Think “rendevous” and “gnocchi”.