"If you lend money [to My people]" (Exodus 22:24). Do not say "money" only, but rather even anything that you lend to him you shall not act toward him as a creditor. And do not say: the Torah said "money," that one should not lend at interest; I will lend to him in wheat. As it is stated, "If you lend money to My people, to the poor person with you." Behold, look upon the poor person as though he were with you. From here our Rabbis said: a poor person in the marketplace and a poor person [in your courtyard] who is in your courtyard takes precedence. A poor relative of yours dwelling in another city and a poor relative of yours — your poor relative takes precedence. "To the poor person with you" — that poor person who is with you and of your own, you shall not act toward him as a creditor. Not because I said to you, "[To a foreigner you may lend at interest]," should you lend to the foreigner and leave aside the Israelite, saying, "for I profit from the foreigner." The Holy One, blessed be He, said: Know that I am the one who made him poor and you rich; I am able to turn you back to make you poor. Rav Nachman said: [See] what is written, "You shall surely give to him [etc.]" (Deuteronomy 15:10) — for it is not written here "for the sake of," but "because of this thing" (ibid.). What is "because of" (bi-gelal)? Know that it is a wheel (galgal): I made him poor and you rich; do not cause Me to turn back the wheel and make you poor. Rabbi Shila said: See what is written, "You shall not harden your heart [etc., from your brother]" (ibid. v. 7). What is "from your brother"? "From a poor person" is not written here, but "from your brother," for the two of you are equal. Do not cause Me to turn back the wheel and make you like him.
The Wheel of Fortune Behind the Mitzvah of Lending to the Poor
Midrash Tanchuma Buber, Mishpatim 8:1
אם כסף [תלוה את עמי], לא תאמרו כסף, אלא אפילו כל דבר שתלוה אותו לא תהיה לו כנושה, ולא תאמר כסף אמרה תורה שלא להלוות ברבית, אני מלוה אותו בחטים, שנאמר אם כסף תלוה את עמי את העני עמך, הוי מביט בעני כאילו הוא עמך, מכאן אמרו רבותינו עני שבשוק ועני [בחצר שלך] שבחצר קודם. עני קרובך ודר בעיר אחרת עני קרובך קודם, את העני עמך, אותו העני שהוא עמך ומשלך לא תהיה לו כנושה, לא בשביל שאמרתי לך [לנכרי תשיך], תהא מלוה לנכרי ומניח לישראל, לומר שאני משתכר מן הנכרי, אמר הקב"ה הוי יודע שאני שעשיתי אותו עני ולך עשיר, יכול אני להחזירך לעשות עני אותך. אמר רב נחמן [ראה] מה כתיב נתן תתן לו [וגו'] (דברים טו י), כי למען אין כתיב כאן, כי (אם) בגלל הדבר הזה (שם), מהו בגלל, הוי יודע גלגל הוא, אני עשיתי אותו עני ואותך עשיר, לא תגרום לי להחזיר את הגלגל, ואעשה אותך עני. אמר ר' שילה ראה מה כתיב לא תאמץ את לבבך [וגו' מאחיך] (שם שם ז), מהו מאחיך, מעני אין כתיב כאן, אלא מאחיך, ששניכם שוים, לא תגרום לי שאחזיר את הגלגל ואעשה אותך כמותו.