Does it happen also when you try to connect to different wifi networks?
I would try to:
Settings>Wifi> tap on the "i" in blue circle at right of your network name, then "Forget this network".
Restart your iphone (turn it off and then back on) and test it.
or
Settings>General>Reset>Reset network settings (you will lose all the wifi network passwords, but nothing else).
Restart your iphone, and test it.
Read also this support guide:
If your iPhone, iPad, or iPod touch won’t connect to a Wi-Fi network - Apple Support
If your issue still persists, have your device inspected at your most convenient Apple Store or Authorized Service Provider: Apple - Find Locations - Location Selector
Regards
Giulio