The magic begins with a 3GS jailbreak released by GeoHot. See, George is fed up with the Dev-Team's insistence on waiting until Apple releases iPhone OS version 3.1. As he puts it:
Normally I don't make tools for the general public, and rather wait for the dev team to do it. But guys, whats up with waiting until 3.1? That isn't how the game is played. We release, Apple fixes, we find new holes. It isn't worth waiting because you might have the "last" hole in the iPhone. What last hole...this isn't golf. I'll find a new one next week.