The baseband is the cellular modem firmware for your iPhone. The baseband is what keeps the device locked to a certain carrier or keeps it factory unlocked. When you perform an unlock, the baseband is exploited to allow you to use your iPhone with any carrier.
If you have an iPhone 2G, you can unlock using BootNeuter.
If you have an iPhone 3G, 3GS, or 4 and have never upgraded past iOS 4.0.2, you can unlock using ultrasn0w.
If you have preserved your baseband using either PwnageTool, Sn0wbreeze, or TinyUmbrella, and you have preserved your pre-iOS 4.1 (not including 4.1) baseband, then you can unlock using ultrasn0w.
If you have an iPhone 3G or 3GS and have updated past iOS 4.0.2, you can unlock by upgrading to the 6.15.00 iPad baseband, but there are risks involved. The risks include: losing your iPhone's GPS functionality and never being able to restore to stock firmware.