David was the youngest of the eight sons of Jesse, and great-grandson of Boaz and Ruth. Of humble origins, David was a shepherd boy, and he presumably learnt his fighting skills when defending his flock from predatory animals. In quieter times, he also developed his musical skills with the flute and harp, which he would use prodigiously in later years.
After God rejected the foolish and corrupt Saul, Israel's first king, he sent Samuel to Bethlehem to anoint David as the successor. Not long after this David was sent for to soothe the troubled spirit of Saul, who suffered from a strange melancholy dejection. He played his harp before the king so skilfully that Saul was greatly cheered, and began to entertain great affection for the young shepherd. This led him to be appointed armor bearer to Saul.
Then followed the famous episode between David and Goliath, where the young lad defeated the Philistine giant and put the enemy to flight, resulting in a great victory for Israel. David became a hero with the people, which incurred the jealousy of Saul, eventually resulting in trying to have him killed.
David fled and installed himself in the Judean desert as the leader of a gang of outlaws and refugees, at times waging war against the Philistines, at other times siding with them. David remained a fugitive until Saul was killed in battle against the Philistines near Mount Gilboa. He then went to Hebron where he was anointed as king of Judah.
All the tribes of Israel came to David at Hebron and said, "We are your own flesh and blood. In the past, while Saul was king over us, you were the one who led Israel on their military campaigns. And the LORD said to you, 'You will shepherd my people Israel, and you will become their ruler.' "
When all the elders of Israel had come to King David at Hebron, the king made a compact with them at Hebron before the LORD , and they anointed David king over Israel.
David was thirty years old when he became king, and he reigned forty years. In Hebron he reigned over Judah seven years and six months, and in Jerusalem he reigned over all Israel and Judah thirty-three years.
(2 Samuel 5:1-5)
During his reign, there were several noteworthy events that occurred, including his capture of Jerusalem, which he made his capital. Three months later David brought the Ark of the Covenant to Jerusalem where it was placed in a new Tabernacle that David had built.
David's greatest mistake was committing adultery with Bathsheba, and then murdering her husband Uriah in an attempt to cover it up. It was a gruesome act for which David later truly repented. Though God forgave him, David's troubles never ceased. One of David's sons, Amnon, assaulted his step sister Tamar, for which the girl's brother Absalom killed him. Absalom later attempted to take over the kingdom from his father David which triggered a civil war.
Other than Bathsheba, David also married Abigail, the former wife of Nabal; Michal, the younger of Saul's two daughters; and Ahinoam of Jezreel.
David died aged seventy and the throne passed on to his son Solomon.