It does seem like magic, but if you think about it for a bit, you will see that a simple computer program can create a spell check program. Let me explain.
First, the computer program would have some sort of basic dictionary in it, or can access it easily. This dictionary obviously has the correct spelling of words. So, when a person types in a word that is not recognized, then it will suggest words that are similar to it. The hope is that one of the suggested words is the word that the writer intends. These suggestions are built off an algorithm to suggest words based on word patterns and combinations.
Second, also keep in mind that there are certain words that people constantly mistype. Computers can look out for those as well, and even auto-correct! This function exists on the iphone and microsoft word. Again the principle that is involved is very similar to the one as described above.
Finally, I should say that the spell checkers are not perfect, and at times we want to spell words in a "new" way. In these instances, you have to ignore it.