Before we delve into why David had to wait before ruling over a unified Israel, we need to know how long the waiting period was. The youngest of eight sons of Jesse the Bethlehemite, he was anointed king by the prophet Samuel (1Samuel 16:1 - 3). While the historian Josephus says that David was ten years old when anointed, modern commentaries place the age at around fifteen.
Beginning of Rule
David began to rule when the tribe of Judah asked him to reign over them when he was about thirty years old. After about seven and one-half years, the remaining tribes of Israel acknowledge him as the sole ruler. Conservatively, therefore, the period between when he was anointed and when he officially began to rule was fifteen years.
The king, like the rest of us, suffered most of his life because of his own sins (adultery with Bathsheba, murder of Uriah her husband, and generally not disciplining his children). His long wait to rule, however, had little to do with the sins of his fathers.
Before God blesses someone or gives them authority of any kind, He tests them over time to see if they will be worthy of the blessing or calling. He looks on the heart of man and not on the outward appearance, as he reiterated to Samuel. The prophet was unaware that Jesse's youngest son David would be the new king.
And it came to pass as they came in, he (Samuel the prophet) saw Eliab (firstborn son of Jesse) and said, "Surely the Lord's anointed is before the Lord." But the Lord said to Samuel, "Do not look on his face, nor on his height because I have refused him, for the Lord does not see as man sees; for man looks on the outward appearance, but the Lord looks on the heart" (1Samuel 16:6 - 7, HBFV)
A Time of Testing
God tested David during the fifteen years between the time of his anointing and him officially assuming power. He was almost continually taunted and harassed by Saul. God eventually concluded that He should not have chosen Saul to be ruler over his people because he was not obedient to his commands.
Though he continued to have many trials during his lifetime, David became the greatest ruler of Israel! He governed God's people for forty years, from 1010 to 970 B.C., and then died at the age of seventy.
God's proving and refining of his character before he began to reign led to him being faithful to the Eternal all the days of his life. Jesus, through his mother Mary, not only traces his bloodline back to the second king of Israel, he will also assume his throne at his Second Coming (Luke 1:32 - 33). David himself, after he is resurrected from the dead, will rule over the tribes of Israel in the coming new world under Christ (see Ezekiel 37).