There is an excellent video on the BBC Learning Zone website for how a speaker works:
A speaker consists of a number of constituent parts including the drive units, the crossover circuit, the cabinet, the tweeter, the mid-range and the woofer. The crossover filter feeds different frequencies to the appropriate drive unit. In each drive unit the signal makes a coil vibrate in a magnetic field, which moves a cone to produce a sound. The cabinet is an essential component in producing the final sound.
Tom is correct, but I’m going to try this a different way.
A sound wave is a wave of slightly denser air (we call it a compression wave). Think of it like ripples in a pond, but rather than little water waves, these are pressure waves in air.
Thus, if you hear a sound, you are actually feeling a change in the air pressure caused by this pressure wave, which is the sound wave.
So, if you want to make a sound from an electric circuit, you need to somehow make the air vibrate in a wave that it is just like the pressure waves from natural sounds. So, how can we turn electricity into movement?
Well, one way is to use an electromagnet and a real magnet. If you send some electricity through a coil of wire, it becomes a little magnet. Send the electricity one way, and it becomes a magnet with the north pole one way and the south pole in the opposite direction. If you reverse the direction of the electricity, you reverse the direction of the north and south pole.
Now, we put our coil of wire near a magnet. We pass the electricity one way, it turns into a magnet and, if the pole of the nearby real magnet is the opposite, they attract and the coil moves a little.
We then suddenly flip the electricity and the magnetism of the coil reverses. It then is repelled by the magnet and moves away a bit.
If you flip the electricity back and forth lots of times, the coil vibrates.
We then attach a strange dish-shaped piece of paper or plastic to the coil. This is called the speaker cone. Then, when the coil vibrates, it causes the cone to vibrate, which causes the nearby air to vibrate. A sound wave is then created, which travels through the air and we can hear it!
What you then need to do, is control the voltage of the electricity very quickly and very carefully and you can make the air vibrate exactly as you want. That way you can get precisely the sounds waves you want and therefore listen to the sort of music that you like!