It's actually not abracadabra magic. It's an artefact of English's adoption of words from many different languages - Latin, Greek, Anglo-Saxon Old English, Scandinavian Norse, Norman French, even Indian and Hawaiian. Each language has its own spelling conventions, which are ported into English alongside the words that are adopted. When you understand the etymologies of various words, you will find that the words that share a common origin also share the same spelling conventions.
Why do we raise pigs but eat pork? Why do we raise sheep but eat mutton? Why do we raise cows but eat beef?
Because during the feudal period of English history following the Norman conquest of 1066, Anglo-Saxon speaking serfs served under the Norman French speaking aristocracy. As a result, farming words (pig, sheep, cow) come from Anglo-Saxon while culinary words (pork, mutton, beef) come from Norman French.
So English spelling is chaotic, yes, but it's because of the many origins of its words, not because it is abracadabra magic. There is method to the madness. It's a fascinating field of study if you're really interested in the reasons behind it, rather than just making up your own explanations.