Pumpkin pie is one of the fastest foods to fill your hunger bar up - meaning you have to eat fewer in order to get full. This is quite helpful in battles.
Farmers in villages will trade 1 emerald for anywhere from 3 to 8 pumpkins/melons. Those emeralds can be used to buy hard-to-collect items like diamond armor, enchanted books, diamond tools, and ender pearls (for starters).