The popular iPhone Dev Team has released the latest version of its tool set, Pwnage, to jailbreak older generation iPhone and iPod Touch which have been updated to iPhone OS 3.1.
Unfortunately, it seems that Apple went to some length to make life more difficult for iPhone 3GS and iPod Touch 3G and 2G owners. Only first generation iPhone and iPod Touch as well as the iPhone 3G can be jailbroken using the current Pwnage.
Only the Mac version is available for now with a Windows port expected fairly soon. Redsn0w for MacOS X and Windows platforms will follow in the "near future" according to the developers.
Jailbreaking your phone allows you to circumvent Apple's restrictions on installing certain applications or using certain mobile phone operators. Apple clearly states that this is illegal as it violates the DCMA and could land the Dev Team in prison.
The iPhone Dev team also provide with an interesting post ono how to future-proof your iPhone 3GS jailbreak. Interesting reading although (a) you need to possess one GS and (b) you need to be aware of the implications of such an operation.
The iPhone-Dev Team blog (link below), provides will all the necessary details as to how to perform the jailbreaking. Just make sure that you backed up all your data and understand that the operation may void your iPhone warranty and make your device unusable.