How to reset an iPhone safely
Your first step should be to head to https://iforgot.apple.com and change your Apple ID password. Since one of the methods of retrieval will be to have a link emailed to you, do this before wiping your iPhone. If you have Activation Lock enabled, you will need to provide this password anyway after wiping.

Don’t create a new Apple ID unless you specifically want a new one.

When you backup to iTunes, make sure your backup is encrypted:


This will allow your account passwords, Health, and HomeKit data to be backed up, and will encrypt your local backup with a password. Do not lose this password!

iTunes should immediately start backing up your iPhone. After that you should be safe to Erase All Contents and Settings on your iPhone, then restore your local backup via iTunes.

Do note that it is not possible (or very difficult) to selectively restore apps, settings, etc. A restore restores all your apps and settings as they were at the time of the backup. However if there was any system corruption, etc. a wipe &amp; restore should take care of such problems.