When you plug your computer, or anything else, into the wall socket, it is extremely probable that the electricity coming through was produced by some sort of electric generator. There are various types, and I'll ignore the differences between AC and DC generators, but all of these depend on a couple of important scientific principles - the conservation of energy and Faraday's law of induction. The conservation of energy states that energy is neither created nor destroyed, but simply changes form. For instance, if I lift the pencil on my desk into the air, my muscles are converting chemical energy from the food I ate into raising the potential energy of the pencil. If I let go of the pencil, that potential energy changes into kinetic energy as the pencil falls. When it hits the desk, you hear the sound, which comes from the kinetic energy of the pencil being converted to the vibrations in the desk and then the air. BTW, this demonstration is much more effective in class if you use a heavy textbook, which tends to wake up dozing freshmen. :) In an electrical generator, the kinetic energy of a spinning turbine (more on what makes that spin in future posts) is transformed into electric current. This is due to electromagnetic induction. In 1931, Faraday described how the motion of a wire relative to a magnetic field leads to a movement of electrons in that wire. If the wire is wrapped around a spinning core between the poles of a magnet (or this can also work if the magnet is doing the spinning).
Redearth76 built this generator using LEGO, neodymium magnets and 30 & 22 gauge wire. He measured 13 volts on the 30 gauge side and 1 volt on the 22 gauge side. He also notes that this is an AC generator, and the LED flashes different colors when positive and negative current is applied, so it blinks back and forth.
Here's another version by goldenbat007
Finally, for a purist version, electric motors work on the reverse of this principle. Instead of using the spinning of an axle to produce an electric current, they use an electric current to produce the motion of an axle. Simple motors can also serve as electric generators, as seen here with a LEGO motor by danky78.