A friend just asked via twitter, “Have a question maybe you can help clear for me. Today we were studying how much God provided for David and of His grace and forgiveness towards David.Of course God commands against adultery,but why does He give David’s wives 2 ‘his companions’ as punishment for what he did with Bathsh. and against Uriah? Isn’t that Him breaking His command as well? (from 2 Samuel 12:11)”
First, excellent question! Second, it shows Christian maturity to be willing to ask hard questions about what God did, is doing, or does. You can continue your maturity by combining the input of an abundance of wise counselors (Proverbs 11:14) with your own diligent searching of the Bible, like the Bereans (Acts 17:11). Here are my thoughts, with further questions always (always!) welcome.
Context, David has lusted over a woman, coveted her, taken her, committed adultery with her. He then attempts to deceive her husband and later orchestrates his murder. With these things and the implications of them David broke all Ten Commandments. And David continues to live unrepentant for roughly a year (nine months for the baby to be born and a sufficient mourning time for Bathsheba, probably largely overlapping each other).
That brings us to where the LORD sends Nathan to confront David about his sins and God’s punishment
Thus says the LORD, ‘Behold, I will raise up evil against you out of your own house. And I will take your wives before your eyes and give them to your neighbors, and he shall lie with your wives in the sight of this sun. For you did it secretly, but I will do this thing before all Israel and before the sun’
Before we look at that closely, let’s consider God’s grace compared to our sin. The Bible says some striking things about sin. Genesis 6:5 reads, “The LORD saw that the wickedness of man was great in the earth, and that every intention of the thoughts of his heart was only evil continually.” Great, every, only, and continually are very strong words to describe our sin (and let’s not pretend the flood that God sent healed the human condition as is shortly thereafter disproved). Jeremiah 17:9 reads, “The heart is deceitful above all things, and desperately sick; who can understand it?” Again, we are in a desperate place when God describes our very heart as more deceitful than everything else. And in Romans 3:10-18 God explains that no one is righteous. So unbelievers are unable to please God (Romans 7:8) and even believers like Noah and Jeremiah and you and I have our every action tainted with sin. But God shows such amazing and incredible grace to even allow us to continue to live. And that’s David. For about a year God allowed David to stew in unrepentance. Romans 2:4 reads, “Or do you presume on the riches of His kindness and forbearance and patience, not knowing that God’s kindness is meant to lead you to repentance?” God graciously waited for repentance instead of giving him what he deserved, an instant end to his life. When no repentance came God graciously sent His prophet Nathan with a parable to penetrate David’s denial of sin and God granted him repentance (Acts 11:18). Then after David admits his sin the LORD puts his sin away and preserves his life (v. 13). So in spite of all the characters of this story deserving death, God preserves them and even David, the most sinful of them (1 Timothy 1:15-17).
Now for the punishment of David – David was a believer, a man after God’s own heart. Believers are given a different punishment than unbelievers. Hebrews 12:7-11 explains that God disciplines believers as a father does to his sons. He does so to bring us into holiness and righteousness. So God puts David through this entire ordeal for David’s own improvement and God’s glory since the LORD is recognized as a just judge when David repents and when his punishment is so public (Exodus 34:6-7, God is just). God also grants David repentance to show that the LORD shows mercy to whom He will (Exodus 33:19). But just as most believers will have to suffer physical death even though they don’t suffer spiritual death, so David has to suffer some of the consequences of his sins though not the death that he deserves (v. 13).
In order to, finally, answer your question of how God is justified even when He sentences punishment that seems to contradict His own commandments we have to review three things: God’s holiness, His sovereignty, and His means of punishment.
First, God is holy and therefore not subject to any law or command or ordinance but only to what He is in Himself. No one can hold Him to a standard of goodness or rightness because He is the standard. Since no one can demand anything from Him and He is the creator and provider and sustainer (Genesis 1, Colossians 1:17), He is the only one who can make demands, everything is owed to Him. Also, since He is holy and we are sinful the divide between the Him and us is infinite, meaning that we deserve infinite punishment (which is why only Christ, who is God, could take our punishment upon Himself and why hell is for eternity).
Second, God is sovereign. Genesis 50:20 is the classic text for God’s sovereignty and our actions and responsibility all working at the same time to God’s established ends. Another verse is Acts 4:27-28, “for truly in this city there were gathered together against your holy servant Jesus, whom you anointed, both Herod and Pontius Pilate, along with the Gentiles and the people of Israel, to do whatever Your hand had predestined to take place.” So perhaps a better question than David’s neighbors and wives would be God predestination of the murder of Jesus Christ. The answer, of course, is that the people involved bear the responsibility for their evil intentions and actions where God “meant it for good” (Genesis 50:20).
Third, God describes Himself as having a passive means of punishment. Romans 1:24, 26, and 28 Paul writes that due to their sin God “gave them up” to further/deeper sin. This is an insight into God’s sovereignty. Though He works all things (Ephesians 1:11) there is a way that He can hide His presence from a person, and thus give them up, so they do not turn to Him but instead turn to sin and more sin.
So God’s sentence to give David’s wives to another was righteous because He did it and we cannot question* Him because He is holy and we are not; it was also righteous because God is sovereign and even in that adultery He “meant it for good;” it was also righteous because God was not actively working evil but instead releasing His grip on certain people so they would follow their sinful natures.
This would be a poor place to end if we didn’t reflect on the cross here. God appointed before the beginning of the world that He would show love to Himself by creating. And He would reveal Himself not only through beauty and truth and purity but through justice and mercy. In order to fully enjoy Himself He decreed a world that would have opportunity for Him to glorify Himself by showing His justice against what opposed Him and His mercy to those who were undeserving. We, like David, break all the commands God’s asks of us. But through Christ God reconciled the world to Himself (2 Corinthians 5:19) by an ultimate show of justice in Him for us and mercy to us because of Him. And therefore to Him be all the glory, forever and ever! Amen and amen!
*Late edit: This is not to say that the questioner was wrong is asking why but that judging God’s sentences for sin ignores the holiness of God and the pervasive sinfulness in humanity. A question that seeks God’s face, to know Him better is completely different than a question that sets a standard up to which we demand He follow/submit to.