You can restore content and settings from a backup, or restore iPhone to factory settings.
Erase then restore iPhone from a backup
Important: You must first create a backup of your iPhone. See Back up iPhone using iCloud or iTunes.
Go to Settings > General > Reset.
Tap Erase All Content and Settings.
Follow the setup assistant when iPhone restarts.
The setup assistant gives you the option to restore iPhone from an iCloud or iTunes backup. (See Turn on and set up iPhone.)
Restore iPhone from an iTunes backup
Important: You must first create a backup of your iPhone in iTunes. See Back up iPhone using iCloud or iTunes.
Connect iPhone to the computer you normally back up to.
Open iTunes on the computer, then in iTunes choose File > Devices > Restore from Backup.
Restore iPhone to factory settings with iTunes
Use iTunes to delete all content and settings from your iPhone, restore iPhone to factory settings, and install the latest iOS software.
Important: Restoring iPhone to factory settings with iTunes deletes all your content and settings, but doesn’t erase it. Deleted information can’t be accessed through the iPhone interface, but it remains on your device. For information about erasing all content and settings, see Erase all content and settings from iPhone.
Connect your device to a computer using USB.
Open iTunes on the computer.
Click the iPhone button near the top of the iTunes window.
In the Summary pane, click Restore iPhone.
See the Apple Support articles Restore your iPhone, iPad, or iPod touch from a backup and If you can’t update or restore your iPhone, iPad, or iPod touch. For more information about iTunes, refer to the Help in the app.