Because David feared God, even that relatively harmless act tormented his conscience.
وَلكِنْ لِأَنَّهُ كَانَ يَخَافُ ٱللهَ ،‏ سَبَّبَ لَهُ قِيَامُهُ بِهذَا ٱلْعَمَلِ غَيْرِ ٱلْمُؤْذِي نِسْبِيًّا عَذَابَ ٱلضَّمِيرِ .‏