According to the Mosaic Law, they deserved to be executed. Although Jehovah punished them, he did not enforce his own law.
لِنُحَلِّلْ فِي مَا يَلِي قِصَّةَ دَاوُدَ حِينَ ٱرْتَكَبَ ٱلزِّنَى مَعَ بَثْشَبَعَ .‏