Before reading about electric generators, it's important to understand a little about electromagnetic force. There are four fundamental interactions/forces in physics.
- Gravity - a weak attraction between any two objects that have mass
- Electromagnetic - attraction/repulsion between electric charges. Responsible for the chemical behaviour of atoms, and many other phenomena.
- Strong nuclear - holds atoms together. Atoms are comprised of protons and neutrons. Protons have a natural electromagnetic repulsion from each other, so the strong nuclear force has to overcome that in order for the nucleus of an atom to be stable.
- Weak nuclear - not sure what this does but it's observable in fission and fusion reactions
Very brief history of our understanding of electromagnetism
Einstein greatly improved our understanding of electromagnetism. Pre-Einsteinian electromagnetism is now referred to as classical electromagnetism. Classical electromagnetism has been around since roughly 1820.
A stable electric field is the simplest to describe, so I'll start there. Electric fields are spherical regions around electric charges, in which a second electric charge will experience and attractive or repulsive force (by spherical I mean it's the same strength in all directions).
A stable magnetic field is a region around a fixed magnet. It's not spherical because magnets have poles, and the flux is strongest near these and inside the magnet. The shape of the field depends on the shape and strength of the magnet. Magnetic fields attract ferromagnetic materials (iron, rare earth metals, various other elemental metals, alloys of the almost any of the aforementioned with carbon, etc) in certain conditions, and will attract or repel other magnets depending on alignment of poles.
Talking about stable fields is all well and good, but most of the interesting stuff starts happening when the fields change. A changing electric field creates a magnetic field, and vice versa. In this way, an electric field can be manipulated to affect magnets, and a magnetic field can be manipulated to affect charged particles (and thus induce a current, which is what a generator does). Maxwell quantified these effects when he published his quite useful equations in 1864. At that point all of the key knowledge enabling modern power generation was known. Steam turbines were significantly improved about twenty years later, but simple steam turbines have been around for a couple of thousand years.
You can make a simple generator by waving a loop of wire around next to a magnet. Tape the magnet to the end of a drinking straw and spin it next to the loop of wire, and you'll get a stronger effect. It won't be strong enough to power a light bulb unless you make the further refinement of winding one side of the wire loop around a pencil to make a tight coil (this multiplies the effect by the number of loops in the coil)... and spinning the magnet really, really fast. You may have seen this or similar apparatus attached to an exercise bike (in a science museum or something).
The differences between that scenario and a modern power generator are simply a matter of size, speed, and optimisation. Because the flux is strongest near the poles of the magnet, you tend to get "blips" of current with nothing in between. This is inefficient, so they have specially shaped electromagnets (coils wrapped around iron bars with grooves in them) to even out the induced current into a near-perfect sinusoidal waveform. The speed of the generator determines the frequency of the AC that is produced (50-60Hz in most places). This is an important consideration in a situation where you have multiple generators feeding power into a grid - they all have to produce the same frequency current.
Sources / further reading
Answers: electrical generator (contains a nice, concise history of the invention)
Britannica: electric generator