This does not seem like an iPhone issue. So "Erase all content and settings" may not be a solution. Try the following. --> If your iPhone, iPad, or iPod touch won't connect to a Wi-Fi ...
Consider more secure wifi configuration.
Change your router’s WiFi to use WPA2-AES (CCMP) with no WPA or TKIP. Updating this setting ensures that your devices always connect in one encryption mode
- TKIP is obsolete and not considered secure. Choose WPA2, the latest encryption standard, with AES encryption for optimal security
- If your router doesn’t specify TKIP or AES, the WPA2 option probably uses AES
Privacy Settings
- Toggle off Location Services. Go to Settings > Privacy > Location Services and turn it off
- Many users find that disabling System Services’ WiFi Networking solves the problem
- Go to Settings > Privacy > Location Services > System Services > and toggle off WiFi Networking
Try a Reset ALL Settings. This is not Erase
Go to Settings > General > Reset > Reset All Settings
- This resets to default everything in Settings, including notifications, alerts, brightness, and clock settings like wake up alarms
- Resetting all settings also reverts all your personalised and customised features like wallpapers and accessibility settings back to factory defaults.
- Performing this action does not impact any of your personal device data, including photos, texts, documents, and other files
- You need to reconfigure these settings once your iPhone or iDevice restarts
Connect to Wi-Fi on your iPhone, iPad, or iPod touch - Apple Support