How does hedging using futures work? I can't understand how it makes sense. From what I've read, corn producers (for example) sell their corn at current price but deliver the corn later, in order to protect themselves from decline in corn prices. 
On the other hand, those who buy corn agree to current price in order to protect themselves from potential increase of corn prices.
But in the end, one of them is going for profit from this (corn producer if prices fall, buyer if prices raise).
Let's say price of corn rose. Essentially, the producer of corn didn't protect himself - he just lost money on that trade.

The only way I see this work for the producer is if there is >50% chance that price of corn will decline, but if that's the case then buyers of corn wouldn't agree to that trade.

So in the end, doesn't it all even out? Sometimes the producer will make money sometimes he will 'lose'.
Producers of corn may not be able to afford a decrease in prices.

Remember that farmers are (usually) not speculating and not “investing”. They are producing a product that they need to offload in order to make money. They have zero interest in uncertainty (again, assuming that most are not speculating). The future price they can receive today may be better than the spot price in 6 months, or it may be worse - you really have no idea, but at least you can lock it in, so that you know what to plan for.

Remember that farmers have two uncertainties about their product when laying the first seed: 1) quantity and 2) price. By hedging the price on some quantify you can reduce your risk significantly (and hence also your upside) which may be far more appealing then the risk of losing everything.