The anointment of King David is a fascinating story (Samuel I, Ch.16). Much like the later cinderella story, HaShem's desire for David surprised his entire family and the holy prophet Samuel.
The Talmud (Pesachim 119a) relates that the following verses (Psalms 118:21-24) describe the story.
אוֹדְךָ כִּי עֲנִיתָנִי וַתְּהִי לִי לִישׁוּעָה.
"I thank You because You answered me, and You rescued me". This was said by David when he was anointed. He felt that HaShem had been with Him all along.
אֶבֶן מָאֲסוּ הַבּוֹנִים הָיְתָה לְרֹאשׁ פִּנָּה.
"The stone that the builders disdained, became the cornerstone". David's father, Jesse, said these words when he realized that although everyone despised David, he still rose to greatness.
מֵאֵת יְהוָה הָיְתָה זֹּאת הִיא נִפְלָאת בְּעֵינֵינוּ.
"This is from HaShem. It's a marvel in our eyes". This was said by David's brothers, who were stunned by the outcome, because they were all presumed to be more qualified for royalty than David.
זֶה הַיּוֹם עָשָׂה יְהוָה נָגִילָה וְנִשְׂמְחָה בוֹ.
"This day was made by HaShem. Let's sing joyously in it" This was the holy prophet's response. Surprised by the result but ready to act and praise HaShem for His great wisdom.
There's something very deep that Rebbe Nachman, and later Reb Nosson, learn from this story. It's natural for us to analyze and calculate logically. When processing information, we tend to immediately engage with it cerebrally. But the Rebbe says (Sichas HaRan 32) "when a person simply follows his emunah, without calculations, he merits [extra] support from HaShem to reach a level of desire that is higher than intellect". As you can see in the sefirot diagram below, the sefira of כתר (Keter), which is associated with desire, is higher in the chart than the sefira of חכמה (Chochmah), which is intellect. The Rebbe means that by way of simple emunah, which is an attribute of the lowest sefira of מלכות (Malchus), one gets super-natural help to rise even above the greatest knowledge, to the ultimate place of closeness with HaShem.
This is the secret of David's anointment. It could be that David's brothers Eliav and Avinadav were smarter and more knowledgable in Torah than he was, but David believed so simply and deeply in HaShem, and in his relationship with HaShem that he rose up to the level of desire. David is the embodiment of the sefira of Malchus. Through his simplicity, ignoring all the calculations (this one's smarter and more fit, that one's older than me etc.), he rose to be the eternal King of Israel.
This is how Reb Nosson understands the mistake of the spies (Hilchos Nedarim 4:17). They used their sechel and not their emunah. They looked at the fortified cities and the giants and they felt inferior. But even more so, they didn't believe that their avodah would matter in Israel. Wouldn't it be greater to be cradled by HaShem in the desert forever? How are we to work the land and attain spirituality on the level we're on now? These were the types of cheshbonos (calculations) they made. On their level , they couldn't appreciate that through simple faith, one can elevate to the highest place.
אֶבֶן מָאֲסוּ הַבּוֹנִים הָיְתָה לְרֹאשׁ פִּנָּה
"The stone that the builders disdained, became the cornerstone". The low level of simple emunah, which anyone can reach, because it's not complex, was scorned and mocked. This is Eretz Yisrael, the land of emunah. There's no rational explanation for this land. It exists in a miraculous way (Torah 7). The spies slandered it, because they over-rationalized. David's brothers humiliated him because they couldn't appreciate his simplicity. But the Holy One, doesn't ignore his loyal ones. Emunah is loyalty and HaShem gives extra help to those that grab hold of it, shrugging aside all the over complicated-logic and reason that clouds our minds with fear and doubt.
ש״ה לב, נדרים ד