After a time period, files on your hard drive get fragmented, and your system slows down because it has to check multiple locations on your drive for those pieces or fragments of files. To keep your computer running more efficiently, use the built-in tool in Windows to defragment those files. Here's how and when you should do it.
Windows 10, like earlier versions of Windows, automatically defragments files on a regular schedule. However, it does not always run consistently, so if you notice files are taking longer to load or you just want to double-check every month or so, you can see how fragmented the drive is in Windows.
A note about Solid State Drives (SSD): SSDs work in a varied way than traditional mechanical hard drives. Stereotype learning is that SSDs don't need to be defragmented and doing so can also wear down the drive. However, Windows defragments SSDs once a month if necessary and if you have System Restore enabled. This isn't something to worry about, though, because the automatic defragmentation is meant to extend your driver's life and performance.
So with SSDs, just let Windows do its tasks and do not worry about defragmentation. You can use the Optimize Drive tool below to do a general optimization of the drive, including sending the TRIM command to the optimization performer. This doesn't do a traditional defragmentation on the SSD, though. For your mechanical drives, here are the steps for how to defragment your drive in Windows 10.
When Windows has completed the task, your drive should say 0% fragmented in the Optimize Drives utility.