A guy on Reddit gave me this explanation.
Roughly speaking, the ATP only counts your 18 best results. For a top player, you have to count Slams, Masters 1000 results (except Monte Carlo, and those you're exempt from), and presumably the WTF if you qualify.
After that, they take your 6 best results from ATP 500 and below. If you've played more than 6 of these events, than if you have a bad result, another result would count. Say, you played Halle last year, but you also played Atlanta. Atlanta was your 7th best result but because you didn't play Halle this year, you get a 0. Then, Atlanta can be used (because it's now in your top 6 events).
Hope that helps.
Oh the reason they use top 18 is to prevent players from playing a lot of tournaments and keep piling up the points. Don't know if it's a great reason, but probably keeps players potentially a bit healthier (some still play a lot anyway).
The rules are a bit different if you're ranked below 30 (e.g., Masters 1000 results don't have to count if you don't get into the draw).