The passage in Sefer Shemot (22:24) teaches im kesef talveh et ami et he-ani imakh – “if you lend money to any of My people, even to the poor” – which is understood by Rav Yosef in the Gemara as teaching that lending to a Jewish person takes precedence over lending to a non-Jewish person; similarly lending to a poor person takes precedence over lending to a wealthy person.
The Meiri derives from this that even lending to a non-Jew is considered to be a good deed, since we need to be taught that we should give priority to someone who is closer to us. Rav Hai Gaon rules that when lending to a non-Jew whose community does not charge interest on loans, Jews should not do so, either, since that would be considered a hillul HaShem (a desecration of God’s name).
These positions stand in stark contrast to the commentaries who interpret the passage in Sefer (23:21) to mean that it is a fulfillment of a positive commandment to charge interest when lending money to a non-Jew. The Rambam, for example, in Hilkhot Malve VeLoveh (5:1), basing himself on a Sifrei, understands the pasuk in as it appears, which means that a Jew is obligated to charge interest when lending money to a non-Jew. The Ramban and many other rishonim disagree, basing themselves on the Gemara on the previous daf (70b), and argue that the Torah is simply contrasting the laws of taking interest from a Jew – which is forbidden – with the laws of lending money to a non-Jew where it is permitted to charge interest, but that there is no requirement to do so. They prove their position by pointing to other cases where the Torah does a similar thing, e.g. when it says kol of tahor tokhelu – every kosher bird you eat, which is not understood as a requirement to eat poultry, but as a positive restatement of the prohibition forbidding non-kosher birds.