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 ...
If you're trying to recover texts or iMessages on iPhone, use iOS 16, Finder, iTunes, or iCloud to retrieve them.