In the fourth year, its fruits shall be consecrated as praise to God (Leviticus 19:24)
After telling us that the fruit of a tree’s first three years is out-and-out verboten, the Torah tells us that the produce of the fourth year – called neta revai – is dedicated to God along the same lines as ma’aser sheini, the second tithe (see Mitzvah #473). What this entails is the owner taking the produce to Jerusalem, to eat it there. (See Talmud Kiddushin 54b for the process equating neta revai with maser sheini.) As with second tithe, the produce can be exchanged for money, which is then spent on food in Jerusalem.
The fourth-year produce of a vineyard is called kerem revai. Kerem revai can be redeemed for money as grapes or as wine. Similarly, olives may be redeemed as oil. Any other produce must be redeemed in its original state. Fourth-year produce is taken to Jerusalem (or redeemed) in its entirety; one does not subtract terumah, tithes or even the usual gifts for the poor.
The reason underlying this mitzvah is that a person should praise and thank Hashem for the good things that He gives us. For this reason, we refrain from using the fruit of a tree until it is ready to provide choice fruits, then we bring those fruits to Jerusalem and treat them as we do maaser sheini. The farmer will delight in God and God will delight in the farmer, hopefully bestowing his crops with further blessing.
A “fringe benefit” of this mitzvah is that it’s one more excuse to travel to Jerusalem, site of the Temple and the center of Torah. God likes us to be exposed to these things as much as possible because they’re good for us!
While the prohibition on the fruit of the first three years applies at all times and in all places, the obligation on the produce of the fourth year only applies in Israel. The opinion of the Rambam (Maimonides) is that it only applies during Temple times and that such produce is only rabbinically-restricted in the absence of the Temple; other authorities maintain that such produce is Biblically-proscribed at all times.
This mitzvah is discussed in the fifth and final chapter of the tractate of Mishna entitled Ma’aser Sheini; it is codified in the Shulchan Aruch in Yoreh Deah 294. It is #119 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos and #16 of the 26 mitzvos that can only be performed in Israel according to the Steipler Gaon.