One way to do this is to simply reboot your system into Safe mode periodically, which among some other built-in maintenance tasks will run the 'fsck' command-line tool to check the hard drive for errors and repair them if found. Unfortunately, formatting errors can happen even if you've just been using your computer in a normal way, so even though your system may be running fine at the moment, it can only benefit from a regular drive check. If your Mac's hard drive is experiencing formatting errors, then the system may show slowdowns, failures to properly save or read data, and even file corruption, and eventually it may not even boot. While periodic maintenance of your Mac is usually not necessary to keep it running in top shape, one exception is periodically checking your hard drive for errors. This is especially true if you use an outdated version of these software packages that may have a bug or two in it. While such routines can be beneficial if a system is experiencing slowdowns, and should not adversely affect the system if implemented correctly, there is potential for something to go awry. You may have even seen advertisements for programs that automate these tasks.
If you are concerned about your Mac starting to run slow or become unstable, you may have looked into regularly running maintenance routines to clear caches, log files, and other temporary items from your system.