Bathsheba was the wife of Uriah, a loyal soldier of King David. One day, while Uriah was away on a military campaign, David remained in Jerusalem, and while strolling on the palace roof, he saw Bathsheba having a bath. He called her to the palace and made love to her.
This was perhaps the gravest fault that David had ever made until then, but then he compounded it by plotting to kill Uriah, when his attempts to make it appear that Uriah was the father of the child that his wife was expecting failed. Incredibly, David used Uriah's own hand to deliver the message that would get him killed!
In the morning David wrote a letter to Joab and sent it with Uriah. In it he wrote, "Put Uriah in the front line where the fighting is fiercest. Then withdraw from him so he will be struck down and die."
So while Joab had the city under siege, he put Uriah at a place where he knew the strongest defenders were. When the men of the city came out and fought against Joab, some of the men in David's army fell; moreover, Uriah the Hittite died. (2 Samuel 11:14-17)
God was angry with David and sent his prophet Nathan to confront the king. He was grief stricken and repented. God forgave him, not only because David was genuinely sorry, but also for the sake of the assigned role that the Israelites were given in God's plan of salvation for all humans.
David then married Bathsheba, but the child from the adulterous incident died. Later, Bathsheba had another son, Solomon, who she helped to succeed David as king in place of Adonijah, the son of another of David's wives.