God's intent was for Samuel to go to Bethlehem where he'd find the new king (Saul’s replacement) and anoint him, hence the horn (1 Samuel 16:1).
We don't really know how the communication between Samuel and God happened but we do know it happened and that Samuel knew who God wanted because in 1 Samuel 16:8
Then Jesse called Abinadab, and made him pass before Samuel. And he
said, Neither hath the Lord chosen this.
What we do know as well is that in 1 Samuel 8:11-12
11 And he said, This will be the manner of the king that shall reign over you: He will take your sons, and appoint them for himself, for his chariots, and to be his horsemen; and some shall run before his chariots.
12 And he will appoint him captains over thousands, and captains over fifties; and will set them to ear his ground, and to reap his harvest, and to make his instruments of war, and instruments of his chariots.
there's a prediction being made which now looking at it we can see David fits the words too.
...what is God’s purpose?
In Jeremiah 30:9
But they shall serve the Lord their God, and David their king, whom I will raise up unto them.
and in Ezekiel 24:23
And I will set up one shepherd over them, and he shall feed them, even my servant David; he shall feed them, and he shall be their shepherd.
we see the promise of a future king to come, a hope for "David", someone whom God describes as “a man after mine own heart” (Acts 13:22). This future king was/is Jesus.
Why Jesus then? In Him we can see that God’s purpose is that we (Jews and Gentiles) "might make known the riches of his glory on the vessels of mercy, which he had afore prepared unto glory" (Romans 9:23).