David enjoyed much favor from God, for he was a man after God’s own heart. In 2 Samuel 24 we catch up to David near the end of his life. David numbered the children of Israel, something the kings were told not to do—their victory was to be found in the Lord.
Upon doing it, David realized his error, but he was punished anyway, and when he was given the chance to put an end and make a sacrifice he went to the threshing floor of Araunah. Araunah offered to give him the floor and the items for the offering, but David would have none of it.
He would not offer an offering to God that cost him nothing.