The Old Testament clearly indicates that David sinned in numbering Israel.(Why that was sin, I’ll probably never know). But the question is: who incited David to sin in this way? Here is the account in 2 Samuel:
Again the anger of the LORD was kindled against Israel, and he incited David against them, saying, “Go, number Israel and Judah.” So the king said to Joab, the commander of the army, who was with him, “Go through all the tribes of Israel, from Dan to Beersheba, and number the people, that I may know the number of the people.”
But David’s heart struck him after he had numbered the people. And David said to the LORD, “I have sinned greatly in what I have done. But now, O LORD, please take away the iniquity of your servant, for I have done very foolishly.” (2 Sam 24:1,2,10)
And here is the account, written centuries later in 1 Chronicles:
Then Satan stood against Israel and incited David to number Israel. So David said to Joab and the commanders of the army, “Go, number Israel, from Beersheba to Dan, and bring me a report, that I may know their number.”
But God was displeased with this thing, and he struck Israel. And David said to God, “I have sinned greatly in that I have done this thing. But now, please take away the iniquity of your servant, for I have acted very foolishly.” (I Chron 21:1,2,7,8)
I don’t know how you all would explain this seeming contradiction, but I explain it as follows:
At an earlier stage the ancient Israelites believed that God brings about both good and evil, a God who brings both joy and suffering to mankind. Satan was understood to be a servant of God who was sent by God to tempt or to test man or to bring suffering or death upon him. But Satan could do nothing without God’s permission (as in the book of Job, where he brought suffering to Job and death to his children with God’s permission).
At a later stage of development the Israelites saw Satan as an independent being who did evil in his battle against God and God’s purposes, a view that carried right into New Testament times where Satan tried to tempt even the Son of God, opposing Him rather than being His agent.