If you have an iPhone 3G, iPod Touch 2g (non-MC version) jailbreaking 4.0 is very simple using redsn0w both on mac and windows by the iPhone Dev Team. This guide was made using a mac and the screenies are from a mac but the process is identical on windows so you can follow this guide as well. Before you continue update your iPhone 3G or iPod Touch 2g (old bootrom) to 4.0 using iTunes.

To check your iPod Touch 2g bootrom run f0recast (mac | win). If it says Tethered Yes then you can not currently jailbreak 4.0.

Now download what you need.

Firmware:
iPhone 3G 4.0 (follow this guide if downloading with Safari)
iPod Touch 2G 4.0 (follow this guide if downloading with Safari)

Software:
redsn0w 0.9.5b5-4 OS X
redsn0w 0.9.5b5 Windows

Plug in your device and turn it off. Run redsn0w. Click browse.



Find the 4.0 firmware IPSW you downloaded for your device. Select it and click Open.



redsn0w processes the IPSW.



IPSW successfully identified! Click Next.

More...