God chose David and allowed ample time to prepare him. Saul still had over 30 years of his reign left at this point. God taught David many lessons as He patiently guided him from being a harp-picking shepherd to being king of the mightiest kingdom in the known world of his day. Patience may well have been the major lesson. Patience is a supreme manifestation of faith.
Impatience sees only self and passing time.
However, even in these failures, God's analysis of David proved true. Here was truly a man after God's own heart. He did not try to justify himself as Saul did. David repented in true contrition. David's choices and decisions in his youth determined his usability in later years.