How does a generator work to produce energy?
First of all, remember that energy can't be created. It can only be converted
from one form to another, and moved from one place to another. The electrical
generator doesn't create or "produce" any energy.
When a coil of wire is moved through a magnetic field, a potential difference
(voltage) appears between the ends of the wire. If a conductor is connected
between the ends, an electric current flows through the wire and the conductor.
An electric generator spins a coil of wire in a magnetic field. The ends of the coil
come out of the generator, and there is electrical voltage/current/energy available
for anything connected between the ends of the coil.
So now you have to ask: "Where does the energy come from ?"
It's the energy that you have to put into the generator in order to spin the coil
in the magnetic field. Whatever runs the generator supplies that energy. It can
be coal, natural gas, or oil, burned to heat water, or nuclear fuel that's decaying
and heating water, to make steam to drive a steam turbine that spins the coil in
the magnetic field inside the generator. It can be a wheel driven by a windmill,
or by falling water running over Niagara Falls or down through Hoover Dam.
You can't get more electrical energy out of the generator than the energy in
the coal, oil, natural gas, uranium, wind, or falling water that you put into it.