From the Super Mario Wiki
A Melon is a fruit found in tropical regions, such as Yoshi's Island. The Melon first appear in Yoshi's Story, where it is the fruit of choice of the Yoshis. There are 30 of these in every level, all of which must be eaten (without consuming any other kinds of fruit) in order to achieve a perfect score. Each Melon awards the Baby Yoshis with a bonus 100 ♥ apiece. Melons also appear in Yoshi Touch & Go, where they give Yoshi twenty eggs when one of them is eaten.
They also appear in Paper Mario where the adult Yellow Yoshi on Lavalava Island trades a Melon for one of Mario's food items. The requirement, however, is that the item be a recipe from Tayce T.. Melons restore 15 HP and don't sell well even at Dry Dry Outpost.