If you need to reset your iPhone to factory settings to resolve an issue, you can back it up to iCloud first and then restore it to keep your data.
• Factory resetting erases all data, apps, and settings from your iPhone, returning it to original condition • Always back up your device before performing a factory reset to avoid permanent data loss ...