Then Herod secretly called the magi and determined from them the exact time the star appeared. And he sent them to Bethlehem and said, “Go and search carefully for the Child; and when you have found Him, report to me, so that I too may come and worship Him.” (NAS95)
If anyone knows how to deal with usurpers and threats to his kingdom, it is Herod. He has kept these groups (scribes and chief priests vs. magi) separated—for his purposes. He calls the magi “secretly.” That means he can control the flow of information, both ways to his benefit. From the scribes and chief priests he learned the “where” of the new born King/Messiah, Bethlehem. Now from the magi, he “inquired diligently” (ἠκρίβωσεν) about the “when” the star appeared. So, Herod is piecing together this threat, calculating all the angles.
Herod only needs one more piece of data: “who.” So he tells them to “search carefully” (ἐξετάσατε ἀκριβῶς), note the second word is the same root as Herod’s activity in 2:7. Herod’s plan comes together now, with the additional instruction that they should come back to Herod and tell him, “so that I too may come and worship Him” (2:8). Obviously Herod has not worshiped anyone, except as necessary to retain his title (“King of the Jews”) which means keeping the Roman Emperor; he would “worship” Caesar, if required.
While Herod seems to be in control, God has an even better plan. Thus, God can use the antics and ravings of pagan rulers for his purpose. Consider Pharaoh:
For the Scripture says to Pharaoh, “for this very purpose I raised you up, to demonstrate my power in you, and that my name might be proclaimed throughout the whole earth.” (Romans 9:17 NAS95).
We further examined how this was true of the rulers of Assyria, which conquered Israel (the ten northern tribes) ~722 BC. And that nation was subsequently conquered by Babylon, which God used to conquer Judah (two southern tribes) ~587 BC. And later still, the Medes and Persians conquered Babylon. And surprise— God calls Cyrus, the ruler of the Medes and Persians “my anointed” (Messiah).
Thus says the LORD to Cyrus His anointed, whom I have taken by the right hand, to subdue nations before him and to loose the loins of kings; to open doors before him so that gates will not be shut… (Isaiah 45:1 NAS05)
So, no matter what the nations and rulers plot… as Psalm 2 relates:
Why are the nations in an uproar and the peoples devising a vain thing?
The kings of the earth take their stand and the rulers take counsel together against the LORD and against His Anointed, … (Psalm 2:7 NAS95)
What they do is ultimately futile, but even more, their evil deeds and plottings are used by God to achieve his perfect plan. And so in Matthew 2, we find the perfect illustration of that. Herod devises, but God brings about justice, appropriate justice for all.