Judah was the Royal tribe (Genesis 49:10)
Why did Samuel anoint Saul from Tribe of Benjamin? (1 Samuel 15:1)
David wasn’t ready yet. Prophesied in the days of Judges (Ruth 4:12).
David will only become eligible for inheritance only after 10th-Generation due to a law in Deuteronomy 23:2 - Bastard being ineligible and must wait for 10th Generation. (Evidence at the end of book of Ruth).
Footnotes:
As you see above, this has implications on the Birth of Jesus to preserve the Royal lineage to ensure David has the right to the Throne and therefore Davidic covenant and then subsequently enabling David's lineage as a platform for Jesus's right to the future promised Throne.