First try restarting your iPhone - Restart your iPhone, iPad, or iPod touch - Apple Support
If that doesn't work, try restoring from a backup - Restore your iPhone, iPad, or iPod touch from a backup - Apple Support
If that doesn't work, try restoring to factory settings - Restore your iPhone, iPad, or iPod to factory settings - Apple Support
If it starts working okay after restoring to factory settings, try using it for a couple of days and then try to restore the backup again. If the problem returns after restoring a backup then you have a corrupt OS or configuration of some kind.
If none of the above options work then the only other thing you can do is have the device evaluated by Apple.