Why was King David spared of the death-for-death rule of Exodus 21?
If one was to give an answer as to why King David was spared from the death penalty for orchestrating the death of Uriah the Hittite would be that in the end God knew the King David would repent of his sins and thus in some measure be an example of a sinner returning to the friendship of God. For this reason, David was spared the Biblical principle of reciprocal justice measure for measure known as "an eye for an eye" commandment found in the Book of Exodus 21:23–27.
23 But if there is serious injury, you are to take life for life, 24 eye for eye, tooth for tooth, hand for hand, foot for foot, 25 burn for burn, wound for wound, bruise for bruise.
26 “An owner who hits a male or female slave in the eye and destroys it must let the slave go free to compensate for the eye. 27 And an owner who knocks out the tooth of a male or female slave must let the slave go free to compensate for the tooth. - Exodus 21:23-27
Another conundrum to this mystery why David was spared resides in the fact that as king he was also judge. “The LORD gave victory to David wherever he went. So David reigned over all Israel, and he administered justice and equity to all his people” (1 Chronicles 18:13–14). We see later the Prophet Nathan to King David pronounce judgement on himself. God thus deceived David making judgement over others through the Prophet Nathan, just as he himself had Uriah the Hittite killed in war by deceptive manner so as to marry Uriah’s wife Bathsheba; so too he was deceived by the hand of God's prophet was realized.
The LORD sent Nathan to David, and when he came to him, he said: “Tell me how you judge this case: In a certain town there were two men, one rich, the other poor. The rich man had flocks and herds in great numbers. But the poor man had nothing at all except one little ewe lamb that he had bought. He nourished her, and she grew up with him and his children. Of what little he had she ate; from his own cup she drank; in his bosom she slept; she was like a daughter to him. Now, a visitor came to the rich man, but he spared his own flocks and herds to prepare a meal for the traveler who had come to him: he took the poor man’s ewe lamb and prepared it for the one who had come to him.” David grew very angry with that man and said to Nathan: “As the LORD lives, the man who has done this deserves death! He shall make fourfold restitution for the lamb because he has done this and was unsparing.” Then Nathan said to David: “You are that man! Nathan’s Indictment. “Thus says the LORD God of Israel: I anointed you king over Israel. I delivered you from the hand of Saul. I gave you your lord’s house and your lord’s wives for your own. I gave you the house of Israel and of Judah. And if this were not enough, I could count up for you still more. Why have you despised the LORD and done what is evil in his sight? You have cut down Uriah the Hittite with the sword; his wife you took as your own, and him you killed with the sword of the Ammonites. Now, therefore, the sword shall never depart from your house, because you have despised me and have taken the wife of Uriah the Hittite to be your wife. Thus says the LORD: I will bring evil upon you out of your own house. I will take your wives before your very eyes, and will give them to your neighbor: he shall lie with your wives in broad daylight. You have acted in secret, but I will do this in the presence of all Israel, in the presence of the sun itself.” David’s Repentance. Then David said to Nathan, “I have sinned against the LORD.” Nathan answered David: “For his part, the LORD has removed your sin. You shall not die, but since you have utterly spurned the LORD by this deed, the child born to you will surely die.” Then Nathan returned to his house. The LORD struck the child that the wife of Uriah had borne to David, and it became desperately ill. David pleaded with God on behalf of the child. He kept a total fast, and spent the night lying on the ground clothed in sackcloth. The elders of his house stood beside him to get him to rise from the ground; but he would not, nor would he take food with them. On the seventh day, the child died. David’s servants were afraid to tell him that the child was dead, for they said: “When the child was alive, we spoke to him, but he would not listen to what we said. How can we tell him the child is dead? He may do some harm!” But David noticed his servants whispering among themselves and realized that the child was dead. He asked his servants, “Is the child dead?” They said, “Yes.” Rising from the ground, David washed and anointed himself, and changed his clothes. Then he went to the house of the LORD and worshiped. He returned to his own house and asked for food; they set it before him, and he ate. His servants said to him: “What is this you are doing? While the child was living, you fasted and wept and kept vigil; now that the child is dead, you rise and take food.” He replied: “While the child was living, I fasted and wept, thinking, ‘Who knows? The LORD may grant me the child’s life.’ But now he is dead. Why should I fast? Can I bring him back again? I shall go to him, but he will not return to me.” -2 Samuel 12:1-23
Critics may have harshly criticized David’s character, but God see things we do not and can bring good out of evil. Many may not have considered the difficult circumstances in which he lived or the manners of his age.
God does not take any pleasure in the death of the sinner, but prefer he repents and turns from his way and live! In this, Scriptures give us an example in King David himself.
But if the wicked will turn from all his sins that he hath committed, and keep all my statutes, and do that which is lawful and right, he shall surely live, he shall not die. - Ezekiel 18:21
Say unto them: ‘As I live, saith the Lord God, I have no pleasure in the death of the wicked, but that the wicked turn from his way and live. Turn ye, turn ye from your evil ways; for why will ye die, O house of Israel?’ - EZEKIEL 33:11
Let us also remember that King David was a repentant sinner as well as a prophet and psalmist of the Most High!