iPhone 5 slowly fails to connect to wifi
If re-setting your network connections didn't help, it could be a hardware problem.

Depending on when it was made, it could be that your WiFi chip inside the phone has pulled  (or, rather, is in the process of pulling) off of the circuit board. Late 4S models also had this problem, and here's how it manifests (progressively):


Very slow speeds / drops connection to the network intermittently
Stops seeing most (or all) networks, but the WiFi button still works, it's not grayed out
Can't turn WiFi on at all, the button is grayed out in the settings menu - but the WiFi button in the control center might appear to work. 


If your phone is under warranty, then take it to an Apple store and have them replace it. Believe it or not, the repair is quite easy, so if it's out of warranty and you know of a place that fixes phones, they've probably got some spare chips and won't charge too much. Apparently, it's a manufacturing defect, so a repaired phone fixed by someone that knows their stuff could last quite some time. 

This has only been a problem with certain 4S and 5 models, you'll see a bunch of people reporting it if you search for something like "iPhone in freezer" - because (believe it or not), putting your phone in a Ziplock and then freezing it for a few minutes has been known to fix the problem for a short time (though I don't recommend doing this).

AFAIK, this isn't an issue with 5C, 5S or recently (as in the last year) manufactured iPhone 5 units. Could be a good opportunity to upgrade, even if you manage to get it fixed.