This reaction happens in nature for a variety of complex reasons. One reason is due to the Second Law of Thermodynamics, which roughly states that the universe tends towards disorder, an especially important concept in biology, chemistry, and physics. When applied to this chemical reaction, we see that the left-hand side of the reaction describes a more ordered initial state, and that the right-hand side describes a less ordered state. Then according to the Second Law, the reaction tends to produce more ADP and Pi than ATP.
The second major reason for the release of energy is due to formation of new chemical bonds, which are more favorable energetically than the relatively weak bond holding the last phosphate in ATP.
The overall reaction is shown below: Click on the products or reactants to go back and forth between views.