Answer: Before we delve into why David had to wait before ruling over a unified Israel, we need to know how long was the waiting period. He was the youngest of eight sons of Jesse the Bethlehemite, is 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.
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 King. Conservatively, therefore, the period between when he was anointed and the time David actually began to officially rule was fifteen years.
David, 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 a period of 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)
God tested David during the fifteen years between the time of his anointing and him officially assuming the reigns of 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, King David became the greatest ruler of Israel! He governed over God's people for forty years, from 1010 to 970 B.C., 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).