Another interpretation of (Leviticus 14:34): "When you come into the land <of Canaan...and I put a plague of leprosy in a house of the land of your possession>." This is what Scripture says (Psalms 73:1): "Surely (akh) [God] is good to Israel." One might think to all <of Israel>; the text therefore teaches (ibid.): "to the pure in heart." In a similar manner you say (Lamentations 3:25): "The LORD is good to those who wait for Him." One might think to all; the text therefore teaches (ibid.): "to the soul that seeks Him." In a similar manner you say (Nahum 1:7): "The LORD is good, a stronghold in the day of trouble." One might think to all; the text therefore teaches (ibid.): "and He knows those who take refuge in Him." In a similar manner you say (Psalms 145:9): "The LORD is good to all." One might think to all; the text therefore teaches (ibid.): "and His mercies are over all His works." In a similar manner you say (Psalms 84:6): "Happy is the man whose strength is in You." One might think to all; the text therefore teaches (ibid.): "in whose heart are the highways" — these are they in whose hearts are the pathways of the Torah. In a similar manner (Psalms 125:4): "Do good, O LORD, to the good." One might think to all; the text therefore teaches (ibid.): "and to those who are upright in their hearts." In a similar manner (Psalms 145:18): "The LORD is near to all who call upon Him." One might think to all; the text therefore teaches (ibid.): "to all who call upon Him in truth." In a similar manner you say (Micah 7:18): "Who is a God like You, who pardons iniquity and passes over transgression?" One might think for all; the text therefore teaches (ibid.): "for the remnant of His inheritance." Therefore (Psalms 73:1): "Surely (akh) God is good to Israel, to the pure in heart." It does not say "God is good to Israel," but rather "Surely (akh) good" — and akh <implies> a limitation: the afflictions which He brought upon them are good. Why? "To the pure in heart" — to purify that day for the world to come. Therefore it is said: "Surely God is good to Israel, to the pure in heart." (Psalms 73:3): "For I was envious of the arrogant when I saw the prosperity of the wicked." I saw their tranquility and I was envious — of these who make profane spaces upon profane spaces (halalim halalim), as it is said (Job 15:20): "All the days of the wicked he writhes (mitcholel)." "The prosperity (shalom) of the wicked": they sit in quiet and security. (Job 21:9): "Their houses are safe, without fear, nor is the rod of God upon them." (Psalms 73:4): "For there are no pangs (chartzubot) at their death, and their body (ulam) is sound." What "pangs"? You were not brought down to nothingness, nor were you bound to suffering. "And their body (ulam) is sound": therefore they are sound as the vestibule (ulam) <of the Temple>.
God Is Good Only to the Pure in Heart - Tanchuma on the Leprous House
Midrash Tanchuma Buber, Metzora 11:1
ד"א כי תבואו אל ארץ וגו'. זש"ה אך טוב לישראל [אלהים], יכול לכל, ת"ל לברי לבב (תהלים עג א). [כיוצא בדבר אתה אומר טוב ה' לקויו (איכה ג כה), יכול לכל, ת"ל לנפש תדרשנו (שם), כיוצא בדבר אתה אומר טוב ה' למעוז ביום צרה (נחום א ז), יכול לכל, ת"ל ויודע חוסי בו (שם), כיוצא בדבר אתה אומר טוב לה' לכל (תהלים קמה ט), יכול לכל, ת"ל ורחמיו על כל מעשיו (שם), כיוצא בדבר אתה אומר אשרי אדם עוז לו בך (שם פד ו), יכול לכל, ת"ל מסלות בלבבם (שם), אלין דשבילייא דאורייתא בלביהון, כיוצא בו הטיבה ה' לטובים (שם קכה ד), יכול לכל, ת"ל לישרים בלבותם (שם), כיוצא בו קרוב ה' לכל קוראיו (שם קמה יח), יכול לכל, ת"ל לכל אשר יקראוהו באמת (שם), כיוצא בדבר אתה אומר מי אל כמוך נושא עון ועובר על פשע (מיכה ז יח), יכול לכל, ת"ל לשארית נחלתו (שם), לפיכך אך טוב לישראל אלהים לברי לבב, אינו אומר טוב לישראל אלהים, אלא אך טוב, אך מיעוט היסורין שהביא עליהם טובים, למה לברי לבב, לברר אותו היום לעולם הבא, לכך נאמר אך טוב לישראל אלהים לברי לבב. כי קנאתי בהוללים שלום רשעים אראה (תהלים עג ג), ראיתי שלותן והייתי מקנא, באלו שהן עושין חללים חללים, שנאמר כל ימי רשע הוא מתחולל וגו' (איוב טו כ), שלום רשעים, יושבים השקט ובטח בתיהם שלום מפחד ולא שבט אלוה עליהם (איוב כא ט), כי אין חרצובות למותם ובריא אולם (תהלים שם ד), מה חרצובות לא הורדתם לאין ולא חרצבתם ליסורין, ובריא אולם, לפיכך הם בריאים כאולם.