Microphones are probably the most abused piece of equipment in the music world. Those poor, diligently working devices are so delicate and precise, and yet they receive the most degrading treatment. Have you seen how pop stars and folk singers behave on stage? They make out with their microphone like it was a sweaty, over-eager lover. It's a gruesome sight that we all seem to put up with for some reason; I suppose in the name of "art". Maybe if singers knew more about microphones they would stop molesting them and actually try using them properly.
Before you can understand how microphones work, you have to understand how sound works. Sound is simply vibrating air particles. That's it. There's nothing fancy going on, just the molecules of air shaking around a bit. For some perspective, wind is actually traveling air particles. For an analogy, sound is like waves on a body of water. The water is mostly just moving up and down. But if you have a hose (wind), spraying water around, that's a lot different.
Microphones are a type of transducer, which means they convert one form of energy into another. In this case they transform the energy of vibrating air (acoustic energy) into electrical energy. A speaker is a precise opposite of a microphone. It converts electrical energy into acoustic energy. Microphones and speakers are so similar, in fact, that if you were to somehow wire up a speaker in the same fashion as a mic, you could actually pick up some rudimentary acoustics (some really weird sounding rudimentary acoustics). You could probably rig up a mic like a speaker and try to get some sound out of it, but I don't know anyone who's tried and I'm pretty sure you'd wreck the microphone in the process.
There are two types of microphones: dynamic and capacitor.
Dynamic microphones use magnets and either a small metal coil or a metal ribbon that vibrates when sound hits it. As it vibrates it generates a voltage at a particular level. Dynamic mikes are rugged but not as precise or, ironically, dynamic as capacitor mikes.
A capacitor mic uses two plates to make a, well, capacitor (which means it holds an electrical charge): a fixed plate and a very thin plastic and metal diaphragm. It looks like this:
When vibrating air pushes the diaphragm around, it changes the space in between the two plates, causing a change in the voltage that it gives out. Tada! A variable electrical signal! Because there aren't any magnets to provide energy, capacitor mikes need what is called a pre-amp; essentially they need to be powered so that the capacitor can always hold a charge.
In addition to their different methods of gathering sound waves, mics are always built to have a particular pickup pattern. This is important to musicians. The pickup pattern is the direction from which a microphone gets its sound. I've made a handy diagram here for you, representing the three most common pickup patterns:
Omnidirectional mikes tends to pick up sound from everywhere. This is good when you're trying to pickup the sound of many people talking or general ambiance. Bidirectional mikes pickup sound sort of in a straight line on either side of the mic. I know people use these since companies keep making them, but I'll be damned if I know why anyone bothers. Cardioid mikes are very common. They are sometimes incorrectly referred to as unidirectional. I say incorrectly, because, if you look at that pattern, you can see that the term 'unidirectional' is kind of misleading. Still, cardioid mikes are the most directional and are generally the best for recording instruments and sounds, since they tend to block out most sounds not in their direct path.
A good thing to remember when looking at microphones is impedance. Impedance is how well a circuit restricts the flow of alternating current. This is measured in ohms (Ω). Now, we're getting into really technical territory and any minute now my brain will jump out of my head, pack up its bags and high-tail it to the nearest Amish village if I don't stop soon, so really what you need to know is that the lower impedance you have in a microphone, the better. With a lower impedance, the mic will have less electrical noise, which means a cleaner sound for your recording.
This is only a very basic overview of microphones. There's a lot more to learn about pickup patterns, transducers, acoustics, and microphone types. But at least now you know a little bit about the subject so you don't have to sound like a total audio weenie in the recording studio or at the music shop. And if you ever get sound out of your microphone, tell me about it, then punch yourself in the face since you just ruined a perfectly good mic.