[DO NOT CUT OFF (Numbers 4:18).] Let our master teach us: One who transgresses the offenses punishable by excision (karet) in the Torah, by what means do they obtain atonement and go out from their excision? Thus did our masters teach: All who are liable to excision and have been flogged are released from their excision, as it is said, "Then the judge shall make him lie down, and he shall be beaten in his presence... forty stripes he may give him, he shall not add... and your brother be degraded" (Deuteronomy 25:2-3); once he has been flogged, behold, he is your brother. And why forty? Because this human being was formed in forty days, and he transgressed against the Torah, which was given in forty days; let him be flogged forty and be released from his punishment. And so you find with the first Adam: when he was commanded and it was said to him, "Of the tree of knowledge [of good and evil you shall not eat...]" (Genesis 2:17), he became liable to death, and the world was struck with forty punishments: ten for Adam, ten for Eve, ten for the serpent, ten for the earth. Therefore, when a person transgresses one of the offenses, let him be flogged forty and go out from his punishment. And so you find concerning each and every matter that the Holy One commanded Moses, warnings and punishments. It is written concerning the Sabbath, "Remember the Sabbath day" (Exodus 20:8) — a warning; and the punishment, "Those who profane it shall surely be put to death" (Exodus 31:14). They came to the wilderness and found one gathering wood, and Moses did not know by what death he was to be put to death; rather, [they placed him in custody, that it might be declared to them by the mouth of the Lord (Leviticus 24:12)] [and they placed him in custody (Numbers 15:34)]. The Holy One said, "The man shall surely be put to death; pelt him with stones" (Numbers 15:35). Immediately Moses arose in prayer and said: Master of the Universe, if a person from Israel sins, is he thus to be stoned? Behold, they will be destroyed! Make for them a remedy. He said to him: Let them be flogged forty and go out from their excision. So too, when the sons of Aaron died, the tribe of Kohath saw them, and they began crying out at Moses, saying: Are we to die thus? The Holy One said to Moses: Just as I made a remedy for Aaron, as it is said, "By this shall Aaron come [into the holy place]" (Leviticus 16:3), so also for the families of Kohath I make such a remedy, that they not die when they come into the Holy of Holies: "And do this for them, that they may live and not die..." (Numbers 4:19). From where? From what they read on the matter: "Do not cut off the tribe of the families of the Kohathites" (Numbers 4:18).
Why Forty Lashes Free a Sinner From Excision in Tanchuma
Midrash Tanchuma Buber, Bamidbar 28:1
[אל תכריתו]. ילמדנו רבינו, העובר על כריתות שבתורה, במה הם מתכפרים, ויוצאין מידי כריתתן, כך שנו רבותינו, כל חייבי כריתות שלקו נפטרו מידי כריתתן, שנאמר והפילו השופט וגו' ארבעים יכנו לא יוסיף וגו' ונקלה אחיך (דברים כה ב ג), כיון שלקה הרי הוא אחיך. ולמה ארבעים, אלא האדם הזה נוצר לארבעים יום, ועבר על התורה שניתנה לארבעים יום, ילקה ארבעים ויצא ידי עונשו, וכן אתה מוצא באדם הראשון כשנצטווה ונאמר לו מעץ הדעת [טוב ורע לא תאכל וגו'] (בראשית ב יז), נתחייב מיתה, ולקה העולם בארבעים עונשין, עשר לאדם, עשר לחוה, עשר לנחש, עשר לאדמה, לפיכך כיון שיעבור אדם על אחת מן העבירות ילקה ארבעים, וכן אתה מוצא על כל דבר ודבר שצוה הקב"ה את משה אזהרות ועונשין, כתיב בשבת זכור את יום השבת (שמות כ ח), אזהרה, ועונש מחלליה מות יומת (שם לא יד), באו למדבר ומצאו מקושש, ולא היה משה יודע באיזו מיתה הוא נהרג, אלא (ויניחוהו במשמר לפרוש להם על פי ה' (ויקרא כד יב)), [ויניחו אותו במשמר וגו' (במדבר טו לד) ], אמר הקב"ה מות יומת האיש רגום אותו באבנים (שם שם לה), מיד עמד משה בתפלה, ואמר רבש"ע אם יחטא אדם מישראל כך הוא נסקל הרי הם מתכלים, עשה להם תקנה, א"ל ילקו ארבעים ויצאו ידי כריתתן, כך כשמתו בני אהרן, ראה אותן שבטו של קהת, התחילו צווחין על משה לאמר כך אנו מתין, א"ל הקב"ה למשה כשם שעשיתי תקנה לאהרן, שנאמר בזאת יבא אהרן וגו' (שם טז ג), ואף למשפחות הקהתי כך אני עושה תקנה, שלא ימותו בבואם אל קדש הקדשים, וזאת עשו להם וחיו ולא ימותו וגו' (במדבר ד יט), מנין ממה שקראו בענין אל תכריתו את שבט משפחות הקהתי.