David decides to take a census
II Samuel, chapter 24, records one of the most puzzling stories in the Bible. II Samuel 24:9 tells us that King David took a census that resulted in a plague that killed seventy thousand Israelites. But counting or taking a census in the Bible could be done in order to determine the availability for war, for the division of ...
The problem was not the census itself, but that David counted the people directly, instead of using something else to count them (Saul used shards of pottery to count the people. Each one gave a shard and then he counted the shards).
See Yuma 22B.
Read all about it here, and some reasons given here.