The default answer is that English words are spelled differently because they used to be pronounced differently, just before English spelling was fixed in aspic with the invention of printing (inconveniently timed to partway through the Great English Vowel Shift).
In Late Middle English, there was [ðeːɹ], which is not a million miles away from its current pronunciation; but their was [ðæiɹ]. (Or at least, that’s what squinting at Middle English phonology for ten minutes tells me.) <ei> in their was written as a diphthong, because it used to be a diphthong, all the way back to Old Norse þeirra. And <e> in there was written as a long vowel (through the final <e>) because it used to be a long vowel, all the way back to Old English thǣr.
In Early Modern English, diphthongs did all sorts of crazy things, one of which was to have some instances of <ei> sound the same as long <e>. (And some others sound like <ei>, and some others sound like <ai>.) So there and their accidentally ended up sounding the same.
If the two words had happened to have ended up sounding the same before, rather than after, spelling was standardised, they likely would have been spelled the same. That’s unless the ambiguity was so intolerable that one of them would end up changing into a different word anyway; but languages are remarkably tolerant of homophony.
For example, Old English has a verb lætan meaning “permit”, and a verb lettan meaning “prevent”. They ended up sounding the same at a time when English spelling was reset (no continuity between Old and Middle English spelling). And in fact let in Middle English did mean both “permit” and “prevent”; it was only more recently that the “prevent” meaning of let (as in “without let or hindrance”) became obsolete.
It takes a Norman Invasion or an Atatürk to reset the spelling of a language so completely. If that hadn’t happened, you’d have likely seen laet and let pronounced identically and spelled differently, to keep continuity with Old English, and not just Middle English. But that kind of reset is the exception, not the rule. And I’m talking about wholesale resetting of the orthography, not the gradualist, consensus-seeking projects listed in much of the Spelling reform article.