Go to your Settings and then tap General. Scroll to the bottom and then select Transfer or reset iPhone. Then, tap Erase All Content and Settings and then tap Erase Now. Enter your password if prompted and then select Erase iPhone to confirm that you want to continue.
As always, if you need any additional help to understand your iPhone's factory settings or to carry them out, consider contacting HelpCloud technicians for remote assistance. For troubleshooting steps, see the Apple support article If you can't update or restore your iPhone. You'll need to have your Apple ID password handy if you have Find My iPhone enabled on your iPhone. Unlike other brands, Apple users know that they can go to any Apple store and have the security of receiving immediate assistance for any problems they may have with their iPhone or other Apple products.
If you don't remember, see the Apple support article If you've forgotten your iPhone's passcode or if your iPhone is disabled. If you received someone else's iPhone and it's still associated with their Apple ID, return it to them and ask them to follow the instructions in the Apple support article What to do before selling, giving away, or trading in your iPhone, iPad, or iPod touch. Doing the hard reset, or factory reset, will ensure that your iPhone is completely cleaned of all the data, and the only apps that remain are the ones that originally came with your iPhone when you first bought it. If you're planning to sell, redeem, or gift your iPhone, iPad, or iPod touch, see the Apple support article What to do before selling, giving away, or trading in your iPhone, iPad, or iPod touch for steps to take before erasing the content from your iPhone.