Somewhere in the OT (I'm too lazy to look up the citation -- it's Sunday mornin') -- God orders a census to be taken of Israel, but when they do the census, it's said to be on Satan's orders, and God kills mega-heaps of people for it. This and the contradictory messages to Balaam sound like a problem drinker who behaves erratically, gets violent, and later either doesn't remember any of it or blames everyone else for being assholes. No wonder the second half of the OT is full of musings of what Israel did wrong and how to get Skydad to be nice again.
II Samuel 24 is the passage to which you refer.
It starts off with God being pissed off at Israel. So since two wrongs make a right Yahweh orders David to take a census.
Joab knows that's against the rules and protests. But David's the king so off they go, numbering the people. Takes 'em 9 months and 20 days. They come up with 1.3 meeeeelion sword-drawing men. Makes David cry because now he knows he's done wrong by doing what Yahweh told him to do. God's just sitting up there with his brows furrowed saying, "Sike!!!"
So Yahweh gives David a Chinese menu. Choose one from Column A. And Column B... well fuggetaboutit. Ain't no column B. Pick your poison.
Column A
- Seven years of famine with a side of disease and starvation
- Three months of you running from your enemies as they poke your ass with spears
- Three days of my meanest angel whipping asses and leaving a big old pile of smoldering butts behind
Well, David's more of a "let's get this over with" kind of guy, and maybe even thinking he'd rather have other folks get their asses whipped than have to deal with the consequences of his choices on a personal level. "I'll take option three."
So for the next three days Yahweh sends his mob enforcer out on a rampage. Dude was pretty handy with the smite button. 70,000 dead men later he's standing just outside Araunah's crib ready to start working Jerusalem over and Yahweh decides it's time to halt things. Or did David decide enough people had died? I don't know, it gets really dumb here (up to now it was really smart). David uses his own money (because he's a "take the consequences myself" kind of guy) and buys some oxen and a threshing floor from Araunah so he can kill some animals to make nice with Yahweh. After all, 50 shekels of silver is a lot bigger sacrifice on his part being King of Israel and all than 70,000 folks who only had to lose their lives because of this.
But everything was just fine in the end. Yahweh just loooooooooves the smell of burning bovine flesh. And spilled blood. Gots to have that spilled blood.
It amazes me that I used to just buy this stuff and blame myself for thinking it was absurd and barbaric. The mental/emotional reaction is very similar to that mechanism that causes abused spouses to blame themselves - it's a warped sense of reality and what's decent.