I had exact same problems connecting iMac to wireless router, even though MacBook had no problem at all. Got a lot of excellent advice from Apple Community members. However, I feel Apple have a problem here and just won't admit it. Below is how my problem was resolved (at least for now).
My technician switched to WEP and made some other adjustments, and downstairs (where I want it) I have 40% quality wireless reception, but can get 70% upstairs in the attic where the hub is located. A little device called iStumbler measures the signal. I am getting by, and it's a dramatic improvement on the horror show endured for the past four months.
Below I quote the solution offered by WiMax (my ISP wireless service), a series of operations I wouldn't dream of attempting lest the remedy becomes worse than the disease.
"There are different levels of wifi encyption and channels all of which are configurable on the router at the web address
http://192.168.15.1:2000 - this can only be accessed when wired into the router with an Ethernet cable.
What i would suggest is, for testing purposes, disable the security on the wifi network entirely (this will give anyone in the area access to your internet connection so do not leave it like this permanently - it does not give them access to your computers - you do not have to worry about that, just your speeds could be lower)
Also we have had many reports of Apple products not working on various wifi frequencies. We have noted that using channel 1,2,3 or 4 work quite well but above this Apple products become unreliable. We have addressed this with Apple, and they accept the issue is with their products but they do not intend to fix it.
Both wifi channel and secturity level can be configured at
http://192.168.15.1:2000