About three days ago my iPhone 5 began to display the same symptoms. It sees wifi networks, (generally only when prompted) and then gives the message "unable to join network." Once or twice it has been able to connect to my home network (which it had worked flawlessly with for some time) but the connection was slow and then was dropped, and abck to the same "cannot connect" problem. This is also true with other networks at work. Have tried pretty much everything in this thread, but no joy.
So then, a visit to the Genius bar and... it connects to the Apple Store network perfectly. Runs like a top... at home it connects, is slow, and loses connnection, and no joy. No connection since.
Apple tells me that since it is out of warranty, I'll have to pay for a new phone. So what is happening? My theory is the wifi hardware is failing, but at least in my case, only the part that specifically is related to 902-11 G and N (somewhat older but very common networks). The newer protocols, AC and AD are not effected; thus the "runs perfectly" syndrome at Apple. I do not believe this is some sort of network problem, or setting problem. Several devices, including two iPhone5's, are funtioning perfectly on our network. Nothing there changed except one device stopped working.
A few months ago, my phone began to have problems with the camera, and was unable to focus. Apple replaced the phone. That was great, but it does point out that the iPhone 5 is having some hardware problems. As these devices become more and more complex, they are having more problems... So my actions now - a new phone with Apple Care.
I continue to think Apple makes good products.They have never been perfect, and will continue to be imperfect. But their support and dependablity is better than the compettition. Plus I have a lot invested in Apple products. So for now, hold your breath, and accept the flaws.