ANSWER: The taking of census is not a sin - but the REASON for doing it could be. The book of Chronicles tells us that Satan, who was against Israel, moved or provoked King David to count his troops (1Chronicles 21:1).
Satan moved in spiritual warfare against the whole nation of Israel - not just the king. With his cunning ways the devil set out to entice David to sin by numbering his army - which David did!
"And again the anger of the LORD was kindled against Israel, and he moved David against them to say, Go, number Israel and Judah." (2Samuel 24:1)
The above verse in the King James Version Bible tends to give a WRONG understanding to the reader. The 1Chronicles 21:1 KJV verse quoted earlier and the below scripture quote from the Young's Literal Translation Bible (YLT) offers a more accurate explanation of what transpired.
"And the anger of Jehovah addeth to burn against Israel, and an adversary [Satan] moveth David about them, saying, `Go, number Israel and Judah.' " (2Samuel 24:1, YLT)
It was SATAN that moved David to disobey God. David seems to have been prompted by a feeling of pride and ambitious curiosity. Because he did this to determine HIS power and to trust in it, it offended God. Of itself, taking a census is not unlawful.
Looking at the scriptures we can know that there is an evil intent by their content. Anytime Satan is involved you can be sure he intends to get someone to sin! He put the thought in David's mind that if he knew the number of young men under his rule (meaning those fit for war) he could brag or boast how great a king he was - by the size of his army!
Joab, commander of David's army, tried to warn him to NOT number Israel and bring an occasion of punishment to the nation (1Chronicles 21:2 - 3). In Hebrew, the word "sin" is often used synonymously with the punishment of sin. In the course of Providence, the people frequently suffer for the misconduct of their rulers.
The primary reason in the Old Testament for taking a census was to know the size of a nation's army and its ability to win wars against other people (Numbers 1:1-4, see also verse 19)!
Easton's Illustrated Bible Dictionary also has some interesting comments regarding this incident with King David. It states that David acted out of pride and a desire to glorify himself. He had come to the point in his life where he was relying far more on his own strength and that of his army rather than on God.
After his sin God told David to choose one of three ways to be corrected. The first way was to have a famine throughout the land for seven years. David knew what famine was like, as he had already suffered famine for three years due to the killing of the Gibeonites. The second choice of correction was to flee from his enemies for three months. Again, David knew what this was like, as he had many times fled from Saul and even had to flee from his son Absalom.
The third way of correction was three days of pestilence (a deadly epidemic) upon the entire land. David choose to, as he put it, 'fall into the hands of the Lord' - which meant the pestilence. Ten of thousands died throughout Israel until the death angel that brought the plague was stopped just before entering Jerusalem. David pleaded for mercy and was told to build an altar to God on a particular threshing floor (2Samuel 24:16 - 18). The pestilence was thus halted.