My belief is that it’s collision avoidance. It’s IE’s way of making sure that if you download files with the same name from different locations that the second doesn’t overwrite the first.
Why sometimes? It may not actually add the number until there’s already a file of the same name. The first one might be ‘normal’, but sometime later (possibly much later) the next file might have the number added.
There’s also a theory floating around that says if you have two (or more) instances of IE running at the same time, it may add the numbers as well.
Most of this is conjecture. I’ve yet to find a difinitive answer.
(My thanks to some of the regulars in the LockerGnome Forums for an assist on the conjectures.)