Although David repented and God forgave him, he still suffered the consequences of his sins. God told David, again through Nathan, that the son conceived in adultery would die. Though David fasted and wept and pleaded with God, God's mind was not changed. The child died (2 Samuel 11 - 12).
So what is the key to understanding this Psalm, the story of David and relating them to our Lenten practice? Although God is merciful and forgiving, slow to anger and rich in mercy, it is better not to sin in the first place. It is from sin that we should fast.