In the third and sixth year of the seven-year Shemittah cycle, ma’aser sheini, the second tithe, was not brought. In those years, land-owners gave ma’aser ani, a special tithe for the poor. At the appropriate times, the poor would go to the farmer and he would give them a prescribed amount of various types of crops. If he has a small harvest and it’s not enough to give each person asking the requisite amount, then he just puts it in front of them and leaves it to those requesting to divide it among themselves.
The reason for this mitzvah is similar to the one for lending money to needy people (Mitzvah #66): surely, God is capable of sustaining everyone. Nevertheless, he wants us to help one another because doing so makes us better people.
This mitzvah only applies in Israel at a time when tithes are observed. In the Talmud, it is discussed in tractate Rosh Hashana (12a-b). It is codified in the Shulchan Aruch in Yoreh Deah 331. This mitzvah is #130 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos and #15 of the 26 mitzvos that can only be observed in Israel as enumerated by the Steipler Gaon.