The formation of water from it's elements produces, in addition to water, a tremendous amount of energy, 572 kJ to be exact.
2H2 + O2 2H2O + ENERGY
This is an example of an exothermic reaction, a reaction that produces energy. It is also an example of what is called a combustion reaction, where a substance (in this case hydrogen gas) is combined with oxygen