Remove any paired devices, such as an iWatch.
Go to Settings and sign out of iCloud.
Go back to Settings and tap General > Reset > Erase All Content and Settings.
If asked for your device passcode or restrictions passcode, enter it. Then tap Erase.