2 Samuel 24:1 And again the anger of the LORD was kindled against Israel, and he moved David against them to say, Go, number Israel and Judah
1 Chronicles 21:1 And Satan stood up against Israel, and provoked David to number Israel.
These two records obviously deal with the same identical event, and yet one time God is said to have moved David and the other time Satan is said to have provoked David to count the people of Israel. Now, how can this be? It appears to be a clear contradiction.
Even though the books of Samuel and Kings, as well as also then Chronicles have records about identical events, a closer look when studying these records reveals that the records in Samuel and Kings are sort of giving the human perspective on the matter. The records in Chronicles however do give God's perspective regarding the exact same situations.
The same principle is true in reference to the record in 2 Samuel 24, where we are given the details about the situation from a human perspective, from man's point of view. Man, without an exact knowledge of the existence and the methods of working of Satan, ascribed both good and evil to God. But in 1 Chronicles, it is then shown that it was not God Himself who suggested such a thing to David for which He later would hold him responsible as a sinner, but rather we learn what really happened. We are granted a look behind the scenes. It was Satan who tempted and successfully provoked David to go against God and count the people of Israel (i.e. the men who were able to bear arms - cp. 2 Samuel 24:2-4.9) instead of on relying upon God's help for Whom the number of soldiers was not relevant anyways.
God Himself did not instigate this situation, for He cannot tempt man to do evil, just as He cannot be tempted with evil either (cp. James 1:13). But, so it seems, that He did allow Satan to tempt king David by which then also Israel did receive its proper judgment and punishment for their unbelieving and rebellious behavior.