Good deeds spring from a pure heart
An example of King David's leadership from II Samuel 24:1-2:
Again the anger of the LORD was kindled against Israel, and he incited David against them, saying, "Go, count the people of Israel and Judah." So the king said to Joab and the commanders of the army who were with him, "Go through all the tribes of Israel, from Dan to Beersheba, and take a census of the people, so that I may know how many there are."
A little background: "Again" indicates that this story is the sequel to an earlier one, perhaps 21:1-14 but we're not sure. The same story is recounted in I Chronicles 21, but there it is Satan, rather than the LORD, who spurs David to take the census. (This tells us that First Chronicles was written later than Second Samuel, in the post-exilic period. It was in this period that talk of Satan became important in the people's thinking and scripture.)
In either case—whether it was the LORD's anger with Israel or Satan's doing—the census was David's idea, not the LORD's. It wasn't until after the fact that David realized what he had done. (Verse 10: But afterward, David was stricken to the heart because he had numbered the people. David said to the LORD, "I have sinned greatly in what I have done. But now, O LORD, I pray you, take away the guilt of your servant; for I have done very foolishly.")
It displeased the LORD so greatly that the people had to be punished. David was given the choice of three punishments, and he chose a three-day-long pestilence, in which 70,000 people died. (See II Samuel 24:12-15.) This event reinforced the belief of that time, that natural calamities were the result of human sin.
No one is sure why taking a census was sinful. The LORD already knew how many people were among the tribes of Israel and Judah. It is obviously David who does not know and wants to know. The census counted only men who were capable of going to war, not women, children or the infirm. Perhaps the order to take a census was the result of David's great pride or even arrogance. In any case, we see the LORD's swift justice in exacting punishment on the people and their leader, causing suffering and a reduction in their numbers.
In this story, David uses the same directive, task-oriented style of leadership that Joshua used when he organized his people to conquer Jerico. The difference is that Joshua was doing what the LORD commanded him; David was doing what he unilaterally decided to do. Joshua's task was a success; David's a disaster.
It can always be a temptation for Christians to do what seems best to them. Good deeds spring not from good intentions, but from a pure heart. Let David's story be a warning to us about how easy it is to stray from the good when we do not seek the LORD's counsel. We must ever and always be in prayer. We must strive to be faithful to God and to scripture, and not to our own whims or the winds of change that blow this way and that around us.