When you delete data, it’s no longer accessible through the iPhone interface, but it isn’t erased from iPhone storage. To remove all of your content and settings from storage, erase iPhone. For example, erase iPhone before you sell it or give it away. If you want to save your content and settings, back up iPhone before erasing it.
You can erase iPhone from Settings . If you’re unable to open Settings, you can use a computer to erase iPhone.
Erase all content and settings from iPhone
Go to Settings > General > Reset.
Tap Erase All Content and Settings.
When iPhone restarts with all content and settings erased, you have the option to set up iPhone as new or restore it from a backup. See Turn on and set up iPhone.
Use a computer to erase all content and settings from iPhone
You can use a Mac or Windows PC to erase all data and settings from your iPhone, restore iPhone to factory settings, and install the latest version of iOS. For example, if you can’t open Settings on iPhone, you can use this approach to restore iPhone to factory settings.
Before iPhone is erased, you have the option to back it up. If you make a backup, you can use the backup to restore your data and settings on your iPhone or on a new device. See Restore iPhone from a computer backup.
Do one of the following:
In the Finder sidebar on your Mac: Select your iPhone, click General at the top of the window, then click Restore iPhone.
To use the Finder to restore iPhone to factory settings, macOS 10.15 or later is required. With earlier versions of macOS, use iTunes to restore iPhone.
In the iTunes app on a Windows PC: Click the iPhone button near the top left of the iTunes window, click Summary, then click Restore iPhone.
Follow the onscreen instructions.
See the Apple Support article If you can’t update or restore your iPhone, iPad, or iPod touch.