Settings > General > Reset > Erase All Content and Settings
If prompted, input the unlock code. Next, input the Apple ID password.
Last but not least, choose the red Erase option.
*When you tap Erase All Content and Settings, it completely erases your device, including any credit or debit cards you added for Apple Pay and any photos, contacts, music, or apps. It will also turn off iCloud, iMessage, FaceTime, Game Center, and other services. Your content won't be deleted from iCloud when you erase your device.
Picture directions showing the above steps