Electromagnetic induction
Moving a magnet around a coil changes the magnetic field inside the coil, which causes current to flow through the coil. This phenomenon is called ‘electromagnetic induction’; the current flowing through the coil is ‘induced current.’
The result is the same if you move the coil instead of the magnet.
If you rotate the coil at a constant angular speed, you can get AC power in the form of a smooth sine wave.
There ain’t no such thing as a free lunch.
In the generator, the generated current causes a magnetic field in the coil. Therefore, the coil’s magnetic field interacts with the magnet’s magnetic field. However, this force always tries to block the movement of the generator.
This can be explained by ‘the law of conservation of energy, because work has to be done to the generator as much as the electrical power generated.