If your iPhone is in range of a Wi-Fi network but you are unable to connect to it, there is either a problem with your Wi-Fi connection or your iPhone is experiencing a glitch. Either way, there are several troubleshooting steps you can take to address the problem.
Reset Your Wi-Fi
The first thing you should do is to make sure that your phone's Wi-Fi is turned on in the "Settings" menu. If it is, try resetting the Wi-Fi on your iPhone. By turning the Wi-Fi off and then back on again, you are forcing your device to search for available Wi-Fi connections. To do this, tap on "Wi-Fi" in the "Settings" menu on your iPhone, move the Wi-Fi slider from "On" to "Off" and then turn it back on again.
Restart or Reboot Your iPhone
Many iPhone problems can be fixed by restarting or rebooting your device. This causes the iPhone to reload, which often fixes minor glitches. To restart your iPhone, hold down the On/Off button until you see the "Slide to power off" bar. Then move the slider from left to right to turn the device off and press the On/Off button again to turn it back on. To reboot your device, hold down the On/Off button and the Home button at the same time until the screen goes black, then wait until it turns back on. Don't worry if it takes a few minutes, rebooting usually does.
Check Your Wi-Fi Connection
Try connecting to the Internet with another device, such as a laptop. If it won't connect either, then the problem is with your Wi-Fi connection and not your iPhone. The first thing to try is resetting your Wi-Fi router, which can be done by turning off the power, then turning it back on again. If this does not work, contact your Internet service provider.
Reset Your Network Settings
If none of the other methods have worked, try resetting your iPhone's network settings. Note that this will cause your iPhone to forget all Bluetooth devices it has ever been paired with, as well as Wi-Fi networks, passwords, and VPN and APN settings. This means you will need to re-pair your Bluetooth devices with your iPhone and set up your Wi-Fi connections again. To reset your network settings, tap on "General" in the "Settings" menu on your iPhone, tap on "Reset" and then tap on “Reset Network Settings.”