Devarim 23:25,26 record that if a person passes through a vineyard or stalks of wheat, then the person is allowed to eat the grapes or wheat in the field but the person is not allowed to gather the grapes in a bucket or use a sickle to cut down the wheat.
The simple explanation of these verses is that any person can enter anybody's fields and eat their crops. This is the approach of Isi ben Yehuda (Baba Metsia 92a). However, as noted by Rav (on Baba Metsia 92a) this permission would ruin a farmer since he/ she would never get to harvest his/ her crops, and hence he/ she will not plant any crops. Thus, the Mishnah (Baba Metsia 7:2, Talmud Baba Metsia, 87a, 87b, and all the mishnayot Baba Metsia 7:2 through the beginning of 7:8) explains that this allowance to eat the crops only applies to a worker working in the field. Luzzatto (on 23:26) expands this allowance to include any person who is permitted to be in the field. While this approach limits the damage to the farmer from the law, it contradicts 23:25,26 since the verses imply that all people have the right to eat the crops.
How can people pass through somebody else's fields? Why is this "passing" not considered trespassing? The poor are allowed to come into fields only after the field has been harvested (Vayikra 19:9; 23:22, Devarim 24:19), while here all people are seemingly allowed carte blanche into other people's fields and can eat until they are satiated.
A different perspective is that instead of viewing the case as one where the passerby is entering the private property of the farmer, it is the farmer who is attempting to plant in ownerless land that is public property. With this understanding, the reference to reecha in 23:25,26, your neighbor, which seemingly indicates that the property in question is private property, should be interpreted to mean that only the vines or stalks of grains is the farmer's property but not the land the crops are situated on. A proof for this is that 23:26 does not use the word fields, as it refers just to the stalks of grains as being the farmer's since the land is not owned by the farmer. With regard to the word vineyard, kerem, in 23:25, the idea would be that kerem could also mean the vines and not necessarily the land on which the vines are situated. Other possible instances where the term kerem means vines are 24:21, Bemidbar 22:24 and Shemot 23:11.
The idea would then be that since the land is ownerless land, any person is allowed to walk in the fields and eat the crops of the field. However, how could a person be allowed to plant his private crops in the public domain?
I believe the laws of 23:25,26 are an attempt to maximize the use of ownerless land. If the ownerless land is land which people use, then it will not be worthwhile for the farmer to plant any crops since the public will either trample and/ or eat his/ her crops. The land will then remain only for the public use. However, some ownerless land is wasted that nobody uses the land either for productive purposes or to pass through. In this case, the most efficient allocation of the land would be to allow a farmer to use the land for planting. The farmer would calculate the number of people who would eat from the crops versus the gain from planting the field, and only use the field if it was worthwhile to develop the field. If the farmer gained from using the field after taking into account the number of people who would eat of the crops, then the field would be used productively, the quantity of food in the country would increase, and any person could eat of the crops.
Note 23:25,26 does not allow the passerby to use a bucket or a sickle to gather the crops since the goal is to balance the production of the farmer with the public needs. If a bucket or sickle is allowed, then one person can take all the crops of the field, which will cause the farmer to let the land lie fallow and the field will not be developed due to the efforts of one person. However, if many people use the land, and they eat a large percentage of the field without needing to use a bucket or a sickle, then the farmer will not plant the land since the benefit from the land to the public is greater than the benefit from growing crops on the land.
In addition, the permission for anybody to enter the fields insures that the farmer would not be able to claim the land as his private property. Furthermore, the permission is only given to plant fields on the ownerless land but not to build buildings.
This idea of balancing between the public and private interests is similar to the Coase theorem in economics, see Schein, A biblical precedent for the Coase theorem? Journal of Markets and Morality, 2004, 7:2, pp. 495-503..