Back it up, back it up. Your old iPhone.
It’s easier if you’re already signed in to iCloud. Your iPhone probably already has backups saved. You can check this in Settings> Your profile> iCloud> iCloud backup and switching it on. If the iCloud backup wasn’t on, give the phone some time to upload all that data, and move on to the next step when the backup is complete.
Another quicker method is to back up your old phone using iTunes on a Mac or PC. Connect your iPhone to your device and switch on iTunes. Click the little iPhone icon on the top-left corner, and select Back Up Now. Give it a few minutes to complete the backup. When you connect your new phone to your computer, it’ll ask you if you want to restore it from iTunes.
Delink your account from the old iPhone.
You should sign out of your account so that it’s not linked anymore to any more of your profiles. This will also make sure that the person who bought your phone won’t have any problem activating anything, can’t access any of your profiles or services using the account on your phone.
Go to Settings>Your Profile. Scroll all the way down, and Sign Out. Your account will be delinked from the phone, and now the new user can reactivate it with his account. You’ll also be signed out of all other services that use that profile, like iCloud, iTunes, App Store, Family Sharing and any other apps you may have set up. The new owner of the phone can’t use your account for anything now.
Note: If you’re getting a new number, you might want to delink your old number from iMessage as well.
After you’ve backed everything up, and signed out of all your accounts you can finally reset your phone. It is as oddly satisfying as it sounds.
Luckily, with iPhones, you don’t have to worry about encrypting your data before deleting it. Every iPhone after the 3GS encrypts data automatically.
Go to Settings > General > Reset > Erase All Content and Settings. And that’s it! When deleting all your data on your old iPhone is finished, it will show you the welcome screen as if it were a brand new phone.