Open Settings > General > Transfer or reset iPhone > Reset > Erase All Content and Settings > Continue. You may be required to enter your passcode or Apple ID and password to confirm your choices. Then follow the prompts.