Go Ahead and Hard Reset your device.
- Hold down the home and power button for 15-20 seconds until the Apple Logo comes up.
Try and stay connected then,
If that does not work, go and reset your network settings.
- Settings> General> Reset> Reset Network Settings
After the device is done restarting, go ahead and try to connect to the WiFi again and see if that resolves it.
Make sure that you also check your Wifi Network and make sure that it is working properly and that other devices are able to connect to it.
If that is the case, you may need to do a restore of your device via iTunes.
Worst case scenario, make an appointment with an Apple Retail Store to have it looked at.
Best of Luck.
Here are some articles to help you out
- Use iTunes to restore your iPhone, iPad, or iPod to factory settings - Apple Support
- If your iPhone, iPad, or iPod touch won’t connect to a Wi-Fi network - Apple Support