Before you erase your device completely, make sure you have a backup ready.
Go to "Settings".
Tap "Reset" and select "Erase All Content and Settings".
You'll get a Warning box appear, with the option to "Erase iPhone" in red.
You'll need to enter your Apple ID password to confirm the action.
You can also perform a factory reset through iTunes.
Plug in your iPhone into your iMac or PC.
You should be able to see a "Restore iPhone' button.
Hard reset your iPhone with Home + Power buttons.
Hold the "Sleep / Wake" button and the "Home" button at the same time until you see the screen goes black.
(You may need to keep holding the buttons even after the red "Power-off" slider appears. If it appears, just keep holding it!)