Ken Kocienda, inventor of autocorrect, wrote a piece for Wired in which he shared a bit of the story behind him and his team at Apple (via Wired).
Inventor of Autocorrect
It started in 2005 when he started working with a small design team to create a touchscreen-based operating system for Project Purple, which would later be revealed as the iPhone. They knew that typing on a small piece of glass would be a bit difficult, and wasn’t even sure if it was possible at first.
It wasn’t easy to figure out how software might come to our rescue and how much our algorithms should be allowed to make suggestions or intervene to fix typing mistakes. I wrote the code for iPhone autocorrection based on an analysis of the words we type most commonly, the frequency of words relative to others, and the errors we’re most likely to make on a touchscreen keyboard.
If I type that I want to make a “peanut butter and Kelly sandwich” the software should know that I meant jelly. As with any machine learning, it takes training. The more you type, the more it learns from your (although there are still mistakes).