Make sure all of your apps are up to date, since many app developers will include performance improvements with app updates.
If your phone is regularly slowing down or freezing, there may be an installed app that is misbehaving and taking up too much of the phone's resources.
If the issue is not being caused by an app, check for updates to your phone's software and if an update is available, download and install it.
In phones with Android 5 or higher, Device Protection may be enabled, which means that after the factory reset, you'll need to sign in using the same Google® Account that was logged into your phone. If you forgot your Google® Account password, use your computer web browser and go to www.google.com/accounts/recovery to reset your password first.
To perform a factory reset:
The phone will reboot and reset.