Why was it a sin for David to count the fighting men?

Question:

In I Chronicles 21, why was it a sin for David to take a census?

Answer:

"When you take a census of the sons of Israel to number them, then each one of them shall give a ransom for himself to the LORD, when you number them, so that there will be no plague among them when you number them. This is what everyone who is numbered shall give: half a shekel according to the shekel of the sanctuary (the shekel is twenty gerahs), half a shekel as a contribution to the LORD. Everyone who is numbered, from twenty years old and over, shall give the contribution to the LORD. The rich shall not pay more and the poor shall not pay less than the half shekel, when you give the contribution to the LORD to make atonement for yourselves. You shall take the atonement money from the sons of Israel and shall give it for the service of the tent of meeting, that it may be a memorial for the sons of Israel before the LORD, to make atonement for yourselves" (Exodus 30:12-16).

There are a few problems with the census that David proposed. First, it appears he did this numbering without charging the half-shekel that was required by the Law. A second problem is that David just wanted to know the number. It wasn't commanded by God nor was it driven by a need. Perhaps David didn't want to charge half a day's wage just to satisfy his curiosity. But the fee was to remind the entire country that they belonged to God because He rescued them from Egypt. Ultimately the fee limited the number of censuses so that people would rely on God and not on themselves. David's census in the long run shows either a desire for pride in his nation or for making plans for war without God's direction.