Gravity caused a huge amount of hydrogen to clump in one area – This is our Sun. Our sun is a great big ball of hydrogen at it’s core.
But there’s so much of the stuff that the pressure is too high and the hydrogen is being fused together to make helium and another material called deuterium. So the energy comes from gravity forcing everything together and making the pressure really high.
We get this energy as heat and light because the process of hydrogen fusing creates lots of energy.
One day the Sun will run out of hydrogen and will hence run out of its energy. But it wont happen for millions of years to come so don’t worry about it. Just know that it wont last forever.
Taking inspiration from the sun, scientists have been trying to master fusion for years – just think, if we could make energy by fusion like the sun does, we’d be able to make more energy than we could have ever need, way more than we can make by nuclear energy (which works by fission – the splitting apart of atoms) and all of our energy problems would be solved. Unfortunately, no one is even close to mastering fusion…yet.