Symbolism, Imagery, Allegory
Why does God punish all of Israel for David taking a census—especially considering that 2 Samuel says God provoked him to take it (however, Chronicles says it was actually Satan who tempted David into the act)?
Seems a little unfair, right?
Well, the idea behind the punishment seems to be that the people are God's, and certain facts about them—like their number—should be left in God's domain. Any attempt by a human to try and number the people is a trespass on God's territory—searching for knowledge that isn't meant for mortals, who are meant to be among the numbered and not the divine numberer himself (God).