Warning: This method no longer works. To jailbreak the latest firmware, check out greenpois0n/limera1n/Pwnage Tool
Redsn0w by DevTeam allows you to jailbreak your device, to get complete control over it (see why you should jailbreak here). Currently, redsn0w version 0.9.5b5-3 allows you to jailbreak a device that has already been upgraded to firmware 4.0, without losing the jailbreak data. However, it will NOT unlock the device, enabling it to be used with different GSM carriers worldwide.
Please note that this tool will NOT work if you have ANY iPhone 3GS, newer iPod Touch G2 or the iPod Touch G3. (On the newer iPod Touch, serial number begins with ‘MC’.)