Jehovah forgave David and lightened the punishment, but He did not shield David from all the bad consequences of his actions.
وَتَوَسَّلَ إِلَى يَهْوَه أَلَّا يَطْرَحَهُ او يَنْزِعَ رُوحَهُ ٱلْقُدُسَ مِنْهُ .‏