David numbered the people. He took a census, which was against what God had said. Thus, God punished David with a plague. However, David prayed for mercy since it was his sin and not the people’s, so God gladly showed mercy. Dave even gave a sacrifice and refused someone offering to help with the financial aspect of his sacrifice. This was a great show of God’s mercy, as well as of David’s willingness to fully repent.
That said, we move on to the next question. I want to know why David was not allowed to build the temple for God. When he expressed his concern for living in a palace while the Lord was only given a tent for a temple, David was told he would not build this building, but his son would. Why?