A completely satisfactory answer to this question is elusive because God’s choice is mysterious from our perspective. However, we can identify several factors: The transfer of favor from Ephraim to Judah may reveal God’s punishing hand as well his grace. After all, the sanctuary at Shiloh in the hill country of Ephraim was full of corruption and incompetence. The sons of the high priest did not treat God’s ark with respect but as a mere magic charm. There is little question that the destruction of Shiloh was an act of God’s anger (see Ps 78:56–64).
It was Israel’s unfaithfulness and misuse of God’s blessings that led to the capture of the ark of the covenant by the Philistines (see Ps 78:60–61; 1Sa 4:11). It was the presumption and disobedience of the people themselves that removed the symbol of God’s presence and blessing from Shiloh. And it was David, trusting in God, who defeated the Philistines and eventually brought the ark to Jerusalem (see 2Sa 5:17–25; 6:17).
Still, the broader question of God’s choice remains. The apostle Paul discussed it by examining God’s relationship with Jacob and Esau. His conclusion was that humans are limited in what they can understand about an incomprehensible God: “I will have mercy on whom I have mercy and I will have compassion on whom I have compassion” (Ro 9:15).