You should take a look at older topic about this same issue.
I'm hoping that this is pure software based problem but it's probably not. Most logicall reason for this issue could be broken antenna or loose antenna connector. But It could be also because of iOS4.
Apple had same kind of issues with iPad and those where fixed with 3.2.1 update. I didn't have issues with my iPad but many had. With iPhone 4 there aren't nearly as much error reports about this issue. But iPod Touch, iPhone 3G and 3GS are having difficult times with iOS4.
There are reports that previously perfectly working 3G/3GS devices are also having these issues (pathetic wifi range) after iOS4 update. It is also reported that some 3G devices have lost wifi completely after update. Those reports bring some hope about thinking it's just because of the software.
On the other hand. Many have changed their devices to new one and wifi problems have dissappeared. I personally tested today my iPhone 4 with co-worker one and wifi range difference was HUGE. Same iOS 4.0.2, same location and mine was giving choppy 1 bar and other one full bars.
Off topic I have to write that there seems to be huge problems in production lines. Mine has pathetic wifi and annoying rattle from back of the phone. My co worker phone has broken earpiece and vibrator is too loud. Third one that we tested had problems with camera, rattle from buttons and completely broken vibrator. Is it like winning in lottery if you get perfectly fine iPhone 4?
Did you ever get this resolved? My iPhone 4 worked fine with wifi, but its screen went black, so I took it to a repair place and they fixed the screen. But, ever since, the wifi signal is so weak it can only be useful when within 5 feet of the router! The repair place said they did everything they knew to identify the problem, but refused to take responsibility for the sudden drop in access to wifi signals. If you found a solution, let me know, please.