Jailbreaking an iPhone doesn't mean you've unlocked it (although to unlock an iPhone, first you'd need to jailbreak it). Rather, it's a hack that opens up the phone's firmware to allow the installation of third-party applications. Just as hardware is the physical part of a device and software consists of the programs you run on the device, firmware is a bit of both. Firmware is code that contains the operating instructions for hardware, such as how an iPhone should function, what features are enabled and any security patches that are needed. Periodically, Apple releases updated firmware to upgrade features and fix bugs.
When an iPhone boots up, it walks through a "chain of trust," which is a series of signature checks among software components always done in a specific order. It begins with boot ROM, moves on to loading low-level bootloader (LLB) software (which controls general data storage and transfer between computers and digital devices, in this case flash memory), then iBoot, then the operating system kernel, and finally the operating system kernel loads the user applications. As the chain of trust is executed, checks are being done for any unauthorized software.
When you jailbreak an iPhone you're modifying, or patching, the iBoot and operating system kernel in this process, rendering them unable to do the digital signature checks that evaluate and distinguish authorized or unauthorized software.
Jailbreaking an iPhone differs from iPhone to iPhone (and iPod Touch) -- it depends on what version of firmware the phone is running and if your computer is Windows or Mac. To do it you need an iPhone, a computer with the latest version of iTunes installed, a downloaded jailbreaking program with instructions and some time. You'll also need to know what version of firmware is installed on your phone.
While we're not giving away the download here, with a little Web searching you can find links to the needed tools -- usually with detailed directions and accompanying screenshots. Some of the more popular programs are QuickPwn (which will jailbreak an iPhone 3G running the most current firmware version 2.0+) and PwnageTool (which can also jailbreak first and second-generation iPod Touches), both from the iPhone dev team. Third party applications can then be browsed, downloaded and installed with software such as Cydia (think of it as the store for nonsanctioned apps), which is conveniently included in jailbreaking tools.
Keeping up to date with jailbreaking software is like a game of cat and mouse -- Apple updates its firmware and hackers scramble to release a jailbreak of the new code.