the energy came from the sun.
The sun increase the temperature on every water surface on the earth which make it transform from liquid to gas, and eventually from cloud.
When the clound condensed, it will fall on top of the geological surface in the form of rain and some of it will fallen to the river and eventually came back to the sea to complete the cycle.