The Davidic Covenant
"I will be to him a father, and he shall be to me a son. When he commits iniquity, I will discipline him with the rod of men, with the stripes of the sons of men, but my steadfast love will not depart from him, as I took it from Saul, whom I put away from before you" (vv. 14-15).
The Mosaic covenant represented a huge step forward in regard to the covenant of grace, as it established laws and rituals designed to help Israel cultivate hope in a Messiah who would save them from their sin and render the perfect obedience that fallen humanity cannot. In this way, the Mosaic covenant pointed beyond itself and demonstrated that while it is an important part of God's ongoing revelation of His grace, something more would be needed to solve the problem of sin. The covenant of grace would need to be unfolded further if salvation was to occur.
Importantly, the Mosaic law calls for obedience that issues forth from a circumcised heart (Deut. 10:12-22), but the provisional nature of its sacrifices, because they had to be repeated and could not cleanse sin, meant that God would have to do more than give the law. He would also have to change the hearts of His people and provide them with a king who would rule in righteousness. Deuteronomy 17:14-20 looks forward to this king, and in the Davidic covenant we see this hope begin to be fulfilled.
Our Creator established His covenant with David after the king brought the ark of the covenant to Jerusalem, which was the divinely appointed place for worship (2 Sam. 6). With the ark in the right location, David longed to build a fitting house for it, a temple for God to dwell in. However, God responded and told the king that he would not be the one to build His house. Instead, the Lord would build a house for David (7:1-17). God initiated a gracious covenant with David and his descendants, noting that He chose David's line, that this line would rule the people of the Lord, and that even if discipline of David's family should prove necessary, God would never take His love away from David and his sons (vv. 8-16).
In time, discipline did become necessary. Most of David's sons according to the flesh were not sons according to the promise, and they led the people of God into flagrant, impenitent sin. Thus, they were exiled as promised in Deuteronomy 28:58-68 (see 2 Chron. 36:15-21). But the exile did not mean that the Lord had broken His promise to never stop loving David and his line. Thus, we have the famous prophecy in Amos 9:11-15 that David would be restored to the throne—not David himself but rather a king from David's line. This king would be disciplined as well, not for His own sin but for the sin of His people. And having atoned for sin, He would be installed as king forever (Rom. 1:1-4; 3:21-26).
Coram Deo
God's gracious promise to David reminds us that God's mercy does not come at the expense of His justice. The Lord pledged to discipline David's line, which ultimately alludes to the justice that the Messiah would receive in behalf of His people. When God forgives us, it is because Christ has satisfied the Lord's just demands in our place. His grace to us is that we do not experience His wrath, and thus we can see His mercy in its glory.