The Torah writes in the Book of Shemot (22:24), "If you lend money to my nation – to the poor among you…" The Sages derive from this verse that lending to a person in need of money constitutes a Misva. Although the verse states, "If you lend," suggesting that lending is optional, elsewhere the Torah speaks about lending in obligatory terms: "Should there be a destitute man among you… you shall surely open your hand to him and lend him that which he lacks…" (Devarim 7-8). In fact, lending money is looked upon as an even greater Misva than giving charity to the poor, as through lending one assists a man in need before he reaches the point where he must accept charity. By lending money, a person helps his fellow Jew in need without subjecting him to the shame and embarrassment associated with accepting charitable donations.
The Misva to lend money applies even to loans given to wealthy people in temporary need of cash. One who offers sound advice concerning investments and business dealings also fulfills this Misva.
If a man is approached by both a poor man and a wealthy man who request a loan, and he can afford to lend to only one of them, the poor man takes precedence. As we cited earlier, the Torah introduces the Misva of lending specifically in the context of lending to the poor, and thus although the Misva includes lending to wealthy people, the poor should nevertheless be granted precedence.
Summary: It is a Torah obligation to lend money to a person in need, even if he is generally wealthy but requires a temporary loan. If both a poor person and a wealthy person are in need of loan, one should afford preference to the poor man.
(Taken from Rabbi Moshe Halevi's "Milveh Hashem," 1:1-2)