It releases hormones that give you a high, particularly dopamine and testosterone. Also it boosts your metabolic rate. Long periods of idleness put humans into an energy conserving torpor. Exercise wakes you up again. It's like coming out of hibernation.
When you're exercising you release Endorphins, which help keep you going, which is why you can sometimes pick yourself up after falling over and not realise how badly hurt you are. That's only a short term effect though.