The king was Balak. He ruled in ancient times, when people believed in magicians and wizards. Balak called the master wizard of his time, Bilaam, to try to curse the Jewish people.
But Bilaam did not curse the Jewish people. Instead, he blessed them with words HaShem put in his mouth. His prophecies contain great blessings for the Jewish people and for the entire world.
Bilaam prophesied about the coming of the Mashiach: “I see it, but not now. I can gaze upon it, but it will not be in the near future. A star shall go forth from Yaakov and a staff shall arise in Israel.”
The Rambam explains, “ ‘I see it, but not now,’ is King David. ‘I can gaze upon it, but it will not be in the near future,’ is King Mashiach. ‘A star shall go forth from Yaakov,’ is King David, and ‘A staff shall arise in Israel,’ is King Mashiach.”
Why does the prophecy mention King David together with King Mashiach? First of all, to strengthen our faith that Mashiach will come. David was born many hundreds of years after Bilaam’s prophecy. We have been waiting even longer for Mashiach. However, we can be sure that the second part of the prophecy will be fulfilled, just as the first part came to pass.
There is also another lesson. Putting the two kings together in the same prophecy shows us that they will do similar things. David spread the study of the Torah and the observance of the mitzvos among all the Jewish people. He defeated all their enemies and brought peace to the land. He brought the Aron HaKodesh to Jerusalem and prepared for the Beis Hamikdash to be built.
These are the type of things Mashiach will do. Mashiach will bring all the Jewish people to keep the Torah. He will lead them to Eretz Yisrael where they will live in peace. And he will build the Beis Hamikdash.
(Adapted from Chidushim UBiurim B’shas, Vol. II, p. 262ff)
