Yet it is also true that David's life speaks to us of God's constancy in His covenant with His children, even when they fail miserably. In this respect David is representative of all true believers, who are in covenant relationship with God through Jesus Christ even though they are still imperfect. For example, see Hebrews 7:22; 8:6-10. The chastening we receive is a mark of a continuing family relationship. Hebrews 12:7-13. In David's case, God permitted no less than 4 children to be born to David by Bath-sheba (spelled Bath-shua in 1 Chronicles 3:5, but the same woman). Was this to replace the four children who died as a result of David's sin? I cannot say for sure, because I do not know whether the first listed child was the one who died a week after his birth. The Bible does not comment directly on this question of restoration of David's dead children, but this is a reasonable inference. A similar principle is stated in Joel 2:25, "So I will restore to you the years that the swarming locust has eaten, the crawling locust, the consuming locust and the chewing locust, My great army which I sent among you." Not only this, but when we look at Luke's genealogy we find that the Messianic line (probably of Mary) passes through Nathan, the third listed child of David and Bath-sheba. Luke 3:31. The royal succession passed through Solomon, the fourth listed son of David and Bath-sheba. Solomon is listed as an ancestor of Joseph, the adoptive and legal father (although not the biological father) of Jesus the Messiah. Matthew 1:6. As with Salmon and the former prostitute Rahab and again with Boaz and the Moabitess Ruth (a foreigner), it is apparent that God once again used an improbable marriage (and in this case one with grossly sinful origins, to boot!) to bring His Son Jesus into the world. I do not know all the reasons why, but I would suggest some:
1) To show His power of sovereign choice;
2) To show His power to overcome human sin;
3) To show His mercy to His chosen people;
4) To show that no human lineage is pure;
5) To show His grace even in the depth of our sin, as with Samson when he was grinding corn;
6) To show His constancy contrasted with our inconsistency; and
7) To show our utter dependence on Him.
God is never taken by surprise nor has any of His plans destroyed by human action or sin. He is the past master of making lemonade from lemons as He is equally masterful in making a beautiful Bride from human rejects. 1 Corinthians 1:26.
We have already noted that Bath-sheba had 4 children with David listed in 1 Chronicles 3:5. That is a clue that even with their horrible start she was able to forge a relationship with him that was deeper than his previous relationships. Most of the other wives that David had taken had one or two children listed at most. Further, Bath-sheba apparently had an unusually strong relationship with her son Solomon. This show up when Solomon's rival approaches Bath-sheba rather than Solomon directly (1 Kings 2:13-25). Solomon would not normally have refused his mother, but he perceived the threat behind Adonijah's request for King David's last companion and ordered Adonijah's execution. But this was not because Solomon lacked respect for his mother -- to the contrary he was greatly attached to her. In Proverbs we read twice, " ... do not forsake the law of your mother." Proverbs 1:8, 6:20. So Bath-sheba taught Solomon well concerning the Word of God, which was highly unusual in that day and time. Bath-sheba's combination of qualities was another reason why God, who sees inside all of us, permitted David's terrible plan to go forward. This is not the only time that God has used women of questionable reputation for His purposes. Mary Magdalene certainly had a questionable past. So did the woman at the well in John 4. The woman who wiped Jesus' feet with her hair had not been a holy woman. Luke 7:36-50.
Still another reason why God permitted David's plan with Bath-sheba to proceed was to highlight the importance of and benefits of repentance from sin. David's sin was deep and his psalms of repentance were heartfelt (especially Psalms 51 and 32). David's grievous sin and recovery was a backdrop for the preaching of both Peter and Paul, who called on their listeners to repent. (Acts 2:38 is an example from Peter; Acts 17:30 is an example from Paul.) John the Baptist demanded repentance (Matthew 3:2) and so did the Lord Jesus Christ (Luke 13:1-5). These are only samples of the call to repentance, but plainly the example and history of David would help many people to understand repentance by example.
Our Lord Jesus posed a question to a Pharisee before dinner in Luke 7:36-50. A woman of immoral history had come to the Lord Jesus and anointed Him, kissed his feet and wiped them with her tears and hair. Those at the table did not understand, so the Lord Jesus asked a question which highlights the connection between divine forgiveness and our love for God. In response to Jesus' question the Pharisee answered correctly that a person will love more if he or she has been forgiven more. The woman at the house had been forgiven much, so she loved much. Perhaps God permitted David to sin with Bath-sheba so that David would understand deep forgiveness and in turn could instruct all succeeding generations, including our own. God is never the author of sin and never commands it. James 1:13-15. However, He permits our sinful wills to express themselves to a certain point for His purposes and then restrains sin as He knows best. Psalm 76:10.