David became the king of all Israel after years of civil war. He made Jerusalem his capital and strengthened its defenses. David sinned greatly by committing adultery with Bathsheba and arranging for her husband Uriah to be killed in battle. God sent the prophet Nathan to convict David of his sin. David repented and God forgave him, but the child from David and Bathsheba's relationship died as a consequence of David's actions. David had many wives and children, and though he faced trials, he remained faithful to God.