On a Biblical level, lending with interest is only forbidden for coreligionists. This is clear from pesukim. This idea is not necessarily discriminatory to the extreme. We currently live in a society which understands the time-value of money, and can understand that charging interest for the use of money is not inherently evil. And so this charging of interest is the default, and is moral. But in establishing a moral and religious society, people who commit to those ideals are helped out in various ways, and this includes free loans to prop people up who are in need.
Later on, some rabbinic voices (R. Huna, perhaps) sought to expand this prohibition against interest to the general world at large, so that one should not loan with interest to gentiles. They couldn’t prohibit it on technical grounds, since halacha is halacha, but they could interpret pesukim do show Divine disapproval of lending with interest to gentiles.
In medieval Europe, many professions were closed off to Jews, and what was left if one wanted to survive and feed one’s children was moneylending. This was certainly permitted on a Biblical level, but it goes against this possible rabbinic and theological idea that one shouldn’t charge gentiles interest. But expansive ideals are wonderful where possible. Not so much when the society with which you are trying to interact doesn’t reciprocate. So there will be technical reasons not to apply it, but there is also the practicality of trying to survive in a hostile world, which will explicitly make an appearance.
The gemara in question (Bava Metzia 70b-71a) reads:
He that by usury and unjust gain increaseth his substance, he shall gather it for him that pitieth the poor.10 Who is meant by, for him that pitieth the poor? — Rab said: e.g., King Shapur.11
R. Nahman observed: Huna told me that [this verse] is needed to show that usury [taken] even from a heathen [leads to loss of one's wealth]. Raba objected to R. Nahman: Unto a stranger tashshik:12 now, what is meant by 'tashshik': surely that 'thou mayest receive usury'? — No: 'thou mayest give usury.'13 [What!] Cannot one do without?14 — It is to exclude 'thy brother,' [to whom thou mayest] not [give usury].15 As for thy brother, is it not explicitly stated, but unto thy brother thou shalt not give usury?16 — [To intimate] that both a positive and negative injunction are violated.17 He [further] raised an objection: ONE MAY BORROW FROM AND LEND MONEY TO THEM ON INTEREST, AND THE SAME APPLIES TO A RESIDENT ALIEN!18 — R. Hiyya, the son of R. Huna, said: This [permission] is granted only [up to]
the [minimum] requirements of a livelihood.1 Rabina said: Here [in the Mishnah] the reference is to scholars. For why did the Rabbis enact this precautionary measure?2 Lest he learn of his ways.3 But being a scholar, he will [certainly] not learn of his ways.
Others referred this statement of R. Huna to [the teaching] which R. Joseph learnt: If thou lend money to any of my people that is poor by thee:4 [this teaches, if the choice lies between] my people and a heathen, 'my people' has preference; the poor or the rich — the 'poor' takes precedence; thy poor [sc. thy relatives] and the [general] poor of thy town — thy poor come first; the poor of thy city and the poor of another town — the poor of thine own town have prior rights. The Master said: '[If the choice lies between] my people and a heathen — "my people" has preference.' But is it not obvious? — R. Nahman answered: Huna told me it means that even if [money is lent] to the heathen on interest, and to the Israelite without [the latter should take precedence].
According to the first reading, R’ Huna interprets the pasuk as indicating Divine displeasure and punishment even to those who charge gentiles interest. Though according to his son, one is allowed up to the requirements of one’s livelihood and no more. While Ravina resolves the contradiction with the Mishna in a different way, that it is prohibited to non-scholars, lest one interact with them and learn from their ways. According to the second reading, R. Huna’s statement modifies a brayta of preference in lending, such that there is never a prohibition against lending with interest to gentiles.
The Rosh writes (and these ideas are also found in Tosafot on the daf) to address the discrepancy between this gemara and conteporary practice:
“Rabbenu Tam would say that this which they conduct themselves nowadays to permit charging gentiles interest is because by laws of Soferim [of Rabbinic invention] we go after the lenient position. And so we establish like the [second] language which teaches this statement of Rav Huna as applying to the brayta, such that Rav Huna never prohibited charging gentiles interest.
And even according to the first language, there is to permit it to us, [based on the clarification by Rav Huna’s son], since everything is “up to making one’s livelihood”, since there is no limit to the [financial] yoke of the king and princes which is placed upon us. And furthermore, since we are living amongst the nations, and it is impossible to profit in any business if we don’t conduct transactions with them. Therefore, there is not to prohibit interest lest [according to Ravina] one learn from their ways, more than any other business transaction.”