Question: "Who incited David to take the census in 2 Samuel 24, God or Satan? Why was God so angry at David for taking the census? Why did God punish the Israelite people when it was David who ordered the census?"
Answer: The parallel account of the incident surrounding the census reveals it was Satan who incited David to take the census: “Satan rose up against Israel and incited David to take a census of Israel” (1 Chronicles 21:1). However, the wording of 2 Samuel 24:1 says that it was God who “moved David” to take the census. This discrepancy can be explained by the understanding that sometimes God sovereignly permits Satan to act in order to achieve His purposes. God uses Satan in various ways, among them the refining, disciplining and purification of disobedient believers (Luke 22:31-32; 1 Corinthians 5:1-5; 2 Corinthians 12:7-10). Such is the case with David. God allowed Satan to tempt him, and David sinned, revealing his pride and allowing God to deal with him for it.
As to why God was angry at David, in those times, a man only had the right to count or number what belonged to him. Israel did not belong to David; Israel belonged to God. In Exodus 30:12 God told Moses, “When you take a census of the Israelites to count them, each one must pay the LORD a ransom for his life at the time he is counted. Then no plague will come on them when you number them.” It was up to God to command a census, and if David counted he should only do it at God's command, receiving a ransom to "atone" for the counting. This is why God was angry again with Israel and is also why David was “conscience-stricken” after he counted Israel. David knew it was wrong and begged God to take away the guilt of his sin (2 Samuel 24:10).
God gave David a choice of three punishments for his sin—three years of famine, three months of fleeing before his enemies, or three days of plague. David chose the third, and the Lord then punished Israel with a plague which killed 70,000 men from Dan in the north to Beersheba in the south. As for why God punished the whole nation for the sin of the king, that is exactly the question David asked in v. 17. Why, when he was the one who had sinned, did the people have to suffer? He even requested that God’s hand be against him and his family only, and that God would spare the people. But as with the account of Job, God chose not to give a reason for His actions. Perhaps it was because of Israel’s multiplied sins and rebellion against God throughout the centuries. Perhaps it was a lesson to the people (and to us as well) that the people suffer when their leaders go astray. The reality is that God didn’t justify His actions with a reason, nor does He have to.
The psalmist tells us, “As for God, His way is perfect” (Psalm 18:30). If God’s ways are “perfect,” then we can trust that whatever He does—and whatever He allows—is also perfect. This may not seem possible to us, but our minds are not God’s mind. It is true that we can’t expect to understand His mind perfectly, as He reminds us “For my thoughts are not your thoughts, neither are your ways my ways, says the LORD. For as the heavens are higher than the earth, so are my ways higher than your ways and my thoughts than your thoughts” (Isaiah 55:8-9). Nevertheless, our responsibility to God is to obey Him, to trust Him and to submit to His will, whether we understand it or not.
As we see in 2 Samuel 24:16 God was grieved because of the things that were happening to His people and called off the punishment. Even through His rebuke God still shows His love and mercy.