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. David, 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 he was ten years old when anointed, modern commentaries place the age at around 15. He 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 he actually began to offically rule was fifteen years.
Like the rest of us King David suffered most of his life because of his own sins (adultery with Bathsheba, murder of Uriah her husband, and generally not disciplining his children). However, the long waiting to rule had little to do with the sins of his fathers. Rather, 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. God looks on the heart of man and not on the outward appearance, as he reiterated to Samuel when he was told to anoint a new king (1Samuel 16:6 - 7).
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, he became the greatest king of Israel, ruling for forty (40) years (from 1010 to 970 B.C.) then dying 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).