Some time ago on Q&A website Quora, I answered a question about why English words aren’t pronounced the way they’re spelt. The original question made particular reference to the name Greenwich, which as you may know is pronounced in modern times as /ɡɹɛnɪtʃ/ (“grenitch”, if you’re not familiar with IPA). But if the first part is “green” and there’s blatantly a W there, then why does this happen?
So in general, English words are spelt the way they were pronounced once upon a time. English spelling has been fixed for ~400 years, but the spellings that were chosen at that time were extremely conservative ones, reflecting the way the language had been spoken about 200 years before that. What that means is that English pronunciation has changed dramatically since the time that the spellings we use today were created. Probably the single greatest pronunciation shift that goes largely missing from modern spellings is the Great Vowel Shift.
In the specific case of Greenwich, it comes from the Old English name Grenewic, which was pronounced something like /ɡre:newɪtʃ/, compared to the modern /ɡɹɛnɪtʃ/. The /w/ has been dropped from the spoken form of the word, as indeed the entire middle syllable has been elided, but otherwise both the spelling and pronunciation have stayed very close to the original form of the name over the last 1,000 years. What’s changed a lot more is the rest of the English language – through the Great Vowel Shift, the Old/Middle English long E /e:/ became /i/. Most words, including our modern word ‘green’, obeyed the shift; however, names are usually much more conservative than ordinary words, and so in ‘Greenwich’ the old pronunciation became somewhat ossified (that is, it diverged differently, hence the loss of the W, but remained closer to the original).
Aside from the Great Vowel Shift, and ordinary elisions like that /w/, another major reason why an English word may not be pronounced how you’d expect from the spelling is if it’s a more recent borrowing, not inherited from Middle English. This is, for example, why ‘mine’ and ‘machine’ do not rhyme. If a word’s been borrowed at some point since the 16th or 17th centuries, chances are we did not change the spelling from the original form (unless the original was a transliteration, in which case we sometimes did). The spelling still likely reflects how the word was pronounced at some point in time, but it might have been a long-ago point in time in a completely different language, with different orthographic rules from ours. The fact that English preserves the spellings of all these different languages we’ve borrowed words from, with their different ways of representing pronunciation, pronunciations that have been assimilated into English and then might’ve changed again anyway, makes the relationship between spelling and pronunciation in English extraordinarily complex.