1. Pride and repentance (1-10)
David gave in to the sin of pride and ordered a census of the fighting men of Israel and Judah. Even Joab the commander could see that it was pointless, but David's order stood. After the census was done, David realized his sin. To his credit, he humbly repented.
2. David's heart (11-25)
David had to choose the punishment that would come on Israel for his sin. Actually, God had his own unseen purpose for punishing Israel (1). But when David saw his people's suffering, he begged God to punish him instead. God used this incident to reveal David's heart and the responsibility of being a shepherd. Gad the prophet told David where to build an altar to stop God's wrath. Araunah, the owner of the property, tried to give it to David for free, but David insisted on paying the full price. He knew that an offering that costs the giver nothing is not meaningful. Jesus is God's most costly offering to save us from sin.