Another interpretation of (Numbers 8:6) TAKE THE LEVITES. This is what Scripture says (Psalms 11:5): THE LORD TESTS THE RIGHTEOUS. The Holy One, blessed be He, does not raise a person to authority until He first tries and examines him; and once he stands firm in his trial, He raises him to authority. And so you find with our father Abraham: the Holy One, blessed be He, tested him with ten trials, and he stood firm in his trial, and afterward He blessed him, as it is said (Genesis 24:1), "And the Lord blessed Abraham in all things." And so too Isaac, He tested him in the days of Abimelech, and he stood firm in his trial, and afterward He blessed him, as it is said (Genesis 26:12), "And Isaac sowed in that land [... and the Lord blessed him]." And so too Jacob, He tested him with all those troubles - with Esau, and with Dinah, and with Joseph, and with how he went forth from the house of his father and his mother, "for with my staff I crossed [this Jordan]" (Genesis 32:11) - and He blessed him, as it is said (Genesis 35:9), "And God appeared to Jacob again [when he came from Paddan-aram, and He blessed him]." And so too Joseph, He tested him with the wife of Potiphar, and he was imprisoned for twelve years, and afterward he came out and was made king, because he stood firm in his trial. This is "THE LORD TESTS THE RIGHTEOUS." And also the tribe of Levi gave their lives for the sanctification of the name of the Holy One, blessed be He, so that the Torah would not be annulled. For at the time when Israel was in Egypt, they despised the Torah and circumcision, and were all idolaters, as Ezekiel reproaches them, as it is said (Ezekiel 20:5), "And you shall say to them: Thus says the Lord God, in the day when I chose Israel [...]." And what is written at the end? (Ezekiel 20:8) "But they rebelled against Me and would not listen to Me; [no man cast away the abominations of his eyes, nor did they forsake the idols of Egypt]." What did the Holy One, blessed be He, do? He brought darkness upon the Egyptians for three days, and slew among them all the wicked of Israel, as He says (Ezekiel 20:36, 38), "[As I entered into judgment with your fathers in the wilderness of the land of Egypt] [...] and I will purge out from among you [the rebels and those who transgress against Me]." And so He says (Song of Songs 2:13), "The fig tree puts forth its green figs" - these are the wicked who were in Israel; "and the vines in blossom give forth their fragrance" - these are the ones who remained, who repented and were received; "Arise, my love, my fair one, and come away" - for the time of the redemption had arrived. But the tribe of Levi were all righteous, and were performing the Torah, as it is said (Deuteronomy 33:9), "For they kept Your word" - this is the Torah; "and guarded Your covenant" - this is circumcision. And not only that, but when Israel made the calf, the tribe of Levi did not join in there, as it is said (Exodus 32:26), "And Moses stood in the gate of the camp and said: Whoever is for the Lord, to me! And all the sons of Levi gathered to him." Once Moses said (Exodus 32:27), "[Put] every man his sword upon his thigh," they immediately did so, and showed no favoritism. And so Moses blesses them, "the one who says of his father and his mother, I have not seen him [...]; for they kept Your word and guarded Your covenant" (Deuteronomy 33:9). When the Holy One, blessed be He, saw that they were all righteous, and tested them and they stood firm in their trial, as it is said (Deuteronomy 33:8), "whom You tested at Massah," the Holy One, blessed be He, immediately said, "And the Levites shall be Mine," to fulfill what is said (Psalms 11:5), "THE LORD TESTS THE RIGHTEOUS." But of the wicked it is written (ibid.), "and the wicked and the lover of violence His soul hates." David said (Psalms 128:1), "Happy is everyone who fears the Lord, who walks in His ways."
Why God Tests the Righteous Before Choosing the Levites
Midrash Tanchuma Buber, Beha'alotcha 13:1
ד"א קח את הלוים. זש"ה ה' צדיק יבחן (תהלים יא ה), אין הקב"ה מעלה את האדם לשררה, עד שבוחן ובודק אותו תחלה, וכיון שהוא עומד בנסיונו, הוא מעלה אותו לשררה, וכן אתה מוצא באבינו אברהם ניסה אותו הקב"ה עשר נסיונות, ועמד בנסיונו, ואחר כך בירכו, שנאמר וה' ברך את אברהם בכל (בראשית כד א), וכן יצחק ניסהו בימי אבימלך, ועמד בנסיונו, ואחר כך ברכו, שנאמר ויזרע יצחק בארץ ההוא [וגו' ויברכהו ה'] (שם כו יב), וכן יעקב ניסהו בכל אותן הצרות, בעשו ובדינה וביוסף, והיאך יצא מבית אביו ואמו, כי במקלי עברתי וגו' (שם לב יא), וברכו, שנאמר וירא אלהים אל יעקב עוד [בבואו מפדן ארם ויברך אותו] (שם לה ט), וכן יוסף ניסהו באשת פוטיפר, והיה חבוש י"ב שנה, ואחר כך יצא ונעשה מלך, על שעמד בנסיונו, הוי ה' צדיק יבחן, ואף שבטו של לוי נתנו נפשם על קדושת שמו של הקב"ה, שלא תבטל התורה, שבשעה שהיו ישראל במצרים, מאסו את התורה, ואת המילה, והיו כולם עובדי ע"ז, שכן יחזקאל מוכיחן, שנאמר ואמרת אליהם כה אמר ה' אלהים ביום בחרי בישראל וגו' (יחזקאל כ ה), ומה כתיב בסוף, וימרו בי ולא אבו לשמוע אלי [איש את שקוצי עיניהם לא השליכו ואת גלולי מצרים לא עזבו] (שם שם ח), מה עשה הקב"ה הביא חשך על המצרים שלשת ימים, והרג בהם כל רשעי ישראל, שכן הוא אומר [כאשר נשפטתי את אבותיכם במדבר בארץ מצרים] [וגו'] וברותי מכם וגו' (שם שם לו לח), וכן הוא אומר התאנה חנטה פגיה וגו' (שה"ש ב יג), אלו הרשעים שהיו בישראל, והגפנים סמדר נתנו ריח (שם), אלו הנשארים שעשו תשובה ונתקבלו, קומי לך רעיתי יפתי ולכי לך (שם), שהרי הגיע קץ הגאולה, אבל שבטו של לוי כולם היו צדיקים, והיו עושים את התורה, שנאמר כי שמרו אמרתך (דברים לג ט), זו התורה, ובריתך ינצורו (שם), זו המילה, ולא עוד אלא כשעשו ישראל את העגל לא נשתתפו שם שבטו של לוי, שנאמר ויעמד משה בשער המחנה ויאמר מי לה' אלי ויאספו אליו כל בני לוי (שמות לב כו), כיון שאמר משה [שימו] איש חרבו על ירכו (שם שם כז), מיד עשו כן, ולא נשאו פנים, וכן משה מברכן האומר לאביו ולאמו לא ראיתיו וגו', כי שמרו אמרתך ובריתך ינצרו (דברים לג ט), כיון שראה הקב"ה שהיו כולם צדיקים, וניסה אותם ועמדו בנסיונם, שנאמר אשר נסיתו במסה (שם שם ח), מיד אמר הקב"ה והיו לי הלוים, לקיים מה שנאמר ה' צדיק יבחן (תהלים יא ה), אבל רשעים כתיב בהם ורשע ואוהב חמס שנאה נפשו (שם), אמר דוד אשרי כל ירא ה' ההולך בדרכיו (שם קכח א).