If your Mac is not performing correctly it can be restored to factory settings. The operation will remove applications and any data created. You will need to back up any files you have created to an external drive or cloud backup medium before resetting.
Depending on the version of Mac OS your machine is using you may need to restore in the following ways detailed below.
Reference:
https://support.apple.com/en-gb/HT204904