I Chronicles 21:1 says that "Satan stood up against Israel, and provoked David to number Israel." II Samuel 24:1 says that "the anger of the LORD was kindled against Israel, and HE moved David against them to say, 'Go, number Israel and Judah.'” So, was it God's fault or was it Satan's fault that Israel was part of an unrighteous census... or, was it Israel's fault? Who was at fault?
The answer is: David! It was David's fault. He was the one who made the decision to count his people. And, the reason he wanted to know how many men he was ruling over, was because of his own sinful pride (11 Samuel 24:3). Indeed, God allowed it... Satan promoted it... Israel deserved it, but David did it. Hmmm... once again it's the inexplicable operation of God's sovereignty and man's responsibility in harmony.
Joab tried to talk David out of this foolishness, but he would not be dissuaded. So, for a little over 9 ½ months David waited to find out just how powerful and influential he was. That's a long time for pride to fester. But, when David had the total (close to a million soldiers), he was happy, right? Wrong! He felt incredibly guilty (II Samuel 24:10). And, there was a price to pay. So, God gave choices to David concerning his punishment, and he chose 3 days of divine judgment.