God can take something that is crimson red and make pure white from it. This is what He did with David's sinful pride. David awakened one morning to find in the mirror a king who was very impressive to him. In fact, he was so impressed with himself that he ordered General Joab to count his soldiers, so that he could know just how big and important he really was. And, against his better judgment, and despite his wise complaints to David, Joab did discover that David was backed by close to 2 million soldiers.
Isn't it interesting how both David and God were displeased when the total number came in? David's conscience cut him deeply, and God poured salt into the wound. David had anticipated that he would feel greatly satisfied in discovering his own strength, but instead he was ashamed. Through Pastor Gad, David accepted his medicine from God's hand; that is, the consequences for his pride. And, he watched helplessly as God's angel killed literally thousands of his subjects. But, it was in that moment that David's blunder was suddenly sanctified and David was elevated to a typological role in messianic prophecy.
Notice the attitude that David had in this sanctified moment (1st Chronicles 21:17). Of course, no OT prophetic harbinger was a perfect picture of the Messiah... so, unlike Christ, in this case David was actually the culprit. However, the attitude that he had was most definitely a foreshadowing of the attitude that Jesus Himself would demonstrate in his incarnation (Psalm 69:9 & Romans 15:3). Jesus' concern and interest was us (John 10:10). Even as David bought the floor of Ornan and sacrificed in fear there, he typified what Jesus would someday do to in order to hold back the wrath of His Holy Father against sin and sinners. (1st Chronicles 21:26 & 27 to Hebrews 5:7).