I say the answer is that it doesn't matter what the farmer and donkey do, they will not be able to get any melons to market. Assuming there's no "lateral thinking" trickery here, which there probably is (the farmer had a car the whole time, we just didn't tell you!) then we can assume that at any point in time the farmer and donkey can chose to (a) not move (b) move 1m toward the market or (c) move back toward the place with the melons. The stipulation on (b) and (c) is that the donkey must have 1 melon before making the movement. They can also (d) give melons to the donkey subject to two stipulations: the number of melons on the donkey cannot exceed 1000 and they may only add melons to the donkey when they are at the place with the melons. There's a final possible action (e) sell melons at the market, but we will never get to that point.
So at the start our options are (a) or (d). In general, (a) will not change anything, so let's just omit that option from consideration. Then our only choice is to perform (d). If we add only one melon then our next options are (b) and (d). If we choose (d), then the donkey will move 1m toward the market and then be stuck because it doesn't have any more melons, so let's choose (b) again. Now the donkey has two melons, so we could choose (d) (d), and then get stuck, or choose (d) (c) but this only has the total effect of reducing our supply of melons by 2. Our last option is to choose (b) again.
This argument repeats itself until we get to 1000 melons, but then we choose (d) until we get to the market where we are, once again, stuck.
I think there is a high chance that the premise of the question is incorrect. Either wrong numbers or wrong conditions. In particular, if you were able to drop melons along the way, the problem would be much more interesting. For instance, here's one way to get one melon to market that way: take three melons, move 1m toward market, drop one melon, move back, take 1000 melons, move 1m, pick up the melon you dropped, go to market. The question of the maximum number of melons is much more interesting in that case. As Gerry Myerson pointed out, in that case the problem is known as "crossing the desert" or "the jeep problem".
I ask again - where did this riddle come from? A book? If so, what is the name/author? In any event, the claim at the end of the problem that the min is 500 makes no sense - even if you omit the restriction of not being able to drop melons on the road you can still easily make it so all the melons are eaten by the donkey by taking 1000 melons and then walking halfway to the market and then halfway back, so wherever you got that information from it is incorrect.