[Another interpretation:] What is the meaning of "and evil shall not dwell with You" (Psalms 5:5)? That the name of the Holy One, blessed be He, does not rest upon evil, except for two things upon which the Holy One, blessed be He, did rest His name. And these are they: "And the LORD watched over the evil and brought it upon us, for the LORD our God is righteous" (Daniel 9:14). Because "the LORD our God is righteous," He "watched over the evil"? Rather, the Holy One, blessed be He, performed an act of righteousness, in that He brought forward and exiled the exile of Jeconiah to Babylon together with the craftsman and the smith and all the mighty ones of the Torah; and they went down to Babylon and established an academy for the Torah. For had it not been so, the Torah would have been forgotten in the exile. Rather, these went out who believed the words of Jeremiah, with the Torah, "and the craftsmen and the smiths, a thousand" (II Kings 24:16). What is "craftsman" (cheresh)? When they would open the Torah, all became like the deaf (chershin). "Smith" (masger): once they would close (sogerin) it, there was none in all Israel who was able to open it. Thus, "for the LORD our God is righteous."
Why God's Name Rests on Evil and the Exile of Jeconiah
Midrash Tanchuma Buber, Tazria 13:1
[ד"א] מהו ולא יגורך רע. שאין שמו של הקב"ה מיחל על הרעה, חוץ משני דברים שיחל הקב"ה שמו עליהם, ואלו הן, וישקד ה' על הרעה ויביאה עלינו כי צדיק ה' אלהינו (דניאל ט יד), משום דצדיק ה' אלהינו וישקד על הרעה, אלא צדקה עשה הקב"ה שהקדים והגלה גלות יכניה לבבל עם החרש והמסגר וכל גבורי התורה וירדו לבבל ועשו תרביץ לתורה, שאילולי כן היתה התורה משתכחת בגלות, אלא שיצאו אלו שהאמינו לדבריו של ירמיה עם התורה והחרש, והמסגר אלף (מ"ב כד טז), מהו חרש, כיון שפותחין בתורה נעשו הכל כחרשין, מסגר משהיו סוגרין לא היה בכל ישראל מי שהיה יכול לפתוח, הוי כי צדיק ה' אלהינו.