The first word in this verse is “im,” literally meaning “if.” Rashi cites the statement of the Talmudic sage Rabbi Yishmael that every instance of “if” in the Torah indicates something that is optional except for three, of which lending money to those in need is one. What Rashi doesn’t mention is the support of this statement: we see from Deut. 15:8 (“you shall surely lend”) that it is an obligation. (For the record, the other two instances of mandatory “ifs” involve bringing the first fruits in Leviticus 2:14 and building the altar in Exodus 20:22. There are similar scriptural proofs that these are likewise obligatory – see Mechilta on Exodus 20:22.)
Giving loans is even greater than giving charity, since by means of lending money, we can hopefully prevent people from reaching the point where they have to beg. Surely God is capable of sustaining all of His children, but he appoints us as His “agents” in this matter. The reason for this mitzvah is that God wants us to get used to helping one another. By doing acts of kindness, we become worthy of receiving His kindness.
This mitzvah applies to both men and women in all times and places. In the Talmud, it is discussed in the tractate of Kesubos on page 67b and in Baba Metzia on 71a. In the Shulchan Aruch, it is found in Choshen Mishpat 97. It is #197 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos and #62 of the 77 positive mitzvos that can be fulfilled today as listed in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.