"And Moses saw the people, that it was exposed (parua)" (Exodus 32:25) — that the Shekhinah had departed from them, and leprosy shone forth upon their forehead, as it is said: "And the leper in whom the plague is, his garments shall be rent and his head shall be exposed (parua)" (Leviticus 13:45). "For a derision among those who rise against them" — for the generations to come, for the nations of the world would taunt Israel concerning the deed of the calf. Immediately he cried out to the sons of Levi and said to them, "Thus says the Lord [the God of Israel: Put every man his sword upon his thigh...]," that you should slay the worshippers of the calf. And from here we have learned that the tribe of Levi did not worship idolatry.
Moses Sees Israel Exposed and the Levites Take Up the Sword
Midrash Aggadah, Exodus 32:25
וירא משה את העם כי פרוע הוא. שנסתלקה שכינה מהם. והצרעת זרחה במצחם, כמו שנאמר והצרוע אשר בו הנגע בגדיו יהיו פרומים וראשו יהיה פרוע (ויקרא יג מה): לשמצה בקמיהם. לדורות הבאים, שהיו אומות העולם מחרפים את ישראל במעשה העגל, מיד צעק לבני לוי ואמר להם כה אמר ה' [אלהי ישראל שימו איש חרבו על ירכו וגו'] שתהרגו בעובדי העגל, ומהנה למדנו ששבטו של לוי לא עבד ע"ז: