Everything that the righteous do, they do through the Holy Spirit. Jacob, when he blessed Judah, blessed him with a lion, as it is said, "Judah is a lion's whelp" (Genesis 49:9) — corresponding to the kingdom of Babylon, of which it is written, "The first was like a lion" (Daniel 7:4); and Hananiah, Mishael, and Azariah are matched against it. He paired Joseph against this wicked kingdom of Rome. Rabbi Samuel bar Nachman said: It is a tradition of aggadah that Esau falls only by the hand of the children of Rachel, as it is said, "Surely the youngest of the flock shall drag them away" (Jeremiah 49:20). And Moses paired the tribe of Levi against the kingdom of Greece — the sons of the Hasmoneans, who were of Levi. Levi is the third tribe, and this kingdom of Greece is the third. Levi has three letters, and Yavan (Greece) has three letters. This one offers up bulls, and that one writes upon the horn of the ox, "We have no portion in the God of Israel." These are many, and those are few. Moses saw them and blessed them, as it is said, "Bless, O Lord, his substance" (Deuteronomy 33:11). And Jacob paired Benjamin against the kingdom of Media, and it is written concerning the kingdom of Media, "And behold, another beast, a second one, like a bear" (Daniel 7:5) — for it is set against the tribe of Benjamin, to which it is likened, as it is said, "Benjamin is a wolf that tears" (Genesis 49:27). Just as the wolf snatches, so did the tribe of Benjamin snatch, as it is said, "And you shall see, and behold, if the daughters of Shiloh come out... then you shall snatch for yourselves" (Judges 21:21).
How the Tribes Were Paired Against the Four Kingdoms
Midrash Tanchuma Buber, Vayechi 13:2
כל מה שהצדיקים עושים ברוח הקודש עושין, יעקב כשבירך את יהודה בירכו באריה שנאמר גור אריה יהודה (בראשית מט ט), כנגד מלכות בבל, שכתיב בו קדמייתא כאריה (דניאל ז ד), וחנניה מישאל ועזריה מזדווגין לה, ליוסף זיווגו כנגד מלכות רומי הרשעה הזו. אמר ר' שמואל בר נחמן מסורת של אגדה היא שאין עשו נופל אלא ביד בניה של רחל [שנאמר אם לא יסחבום צעירי הצאן (ירמיה מט כ) ]. ומשה זיווג שבטו של לוי כנגד מלכות יון בני חשמונאי שהיה מלוי, ולוי שבט שלישי הוא, וזו מלכות יון שלישית, לוי שלש אותיות, ויון שלש אותיות זה מקריב פרים וזה כותב על קרן השור אין להן חלק באלהי ישראל, אלו מרובין ואלו מועטין, ראה אותן משה ובירכן, שנאמר ברך ה' חילו וגו' (דברים לג יא), ויעקב זיווג לבנימן כנגד מלכות מדי, וכתיב במלכות מדי, וארו (חיווא) [חיוה] אחרי (תיניינה דמייא) [תנינה דמיה] לדוב (דניאל ז ה), שהרי הקישה כנגד שבט בנימן שנמשל בו, שנאמר בנימן זאב יטרף, מה הזאב הזה חוטף כך היה שבטו של בנימן חוטף, שנאמר וראיתם (את) [והנה אם יצאו] בנות שילה וגו' וחטפתם לכם (שופטים כא כא).