How does a quartz crystal work?
Quartz is a piezoelectric material, which means that if you mechanically deform it, it develops charges on its surface. Similarly, if you place charges on its surface, it causes mechanical stress in the crystal. The way a quartz crystal benefits a circuit is that mechanically the crystal acts much like a tuning fork, with a natural resonant frequency, and the piezoelectric property allows that to be coupled into an electronic circuit. Since the resonant frequency is mainly determined by the physical size and shape of the quartz, you get a frequency reference that is much less sensitive to temperature than you would get using just LC circuits.
There are already two great answers, so I am just going to try to give a different explanation of the same thing.
Background
So, in a Pierce oscillator you have a digital system connected to a crystal oscillator.Now you have probably seen how logic gates switch state, with a specified rise time. If you put any time into learning about Electromagnetic Compatibility or just high speed digital design (the best book in existence being the one by Johnson), you will learn that this can be looked at as a wide range of frequencies.
What the crystal does
There are two ways of looking at what the crystal does, from the frequency domain and from the time domain. I will start with the frequency domain due to personal preference. I push every electrical engineer I work with to become at home with the frequency domain; many problems become simple here, and complicated responses have meaning.Frequency Domain
From the perspective of the frequency domain, a crystal is a filter at a very specific frequency with a very high Q(quality) factor. This means that of all of those frequencies you generate, you only allow the specific one the crystal allows through.Time Domain
The other way is to think of a gate tied back on itself. If there was nothing there, it would create a square wave with a frequency equal to the delay, but this frequency is not extremely reliable, and also will vary based on many manufacturing parameters. This is where the crystal affects it. If the crystal has a rising edge placed on it, it will only "pass through" the signal at the frequency it has selected for. Suddenly, the 100MHz square wave becomes a 20MHz sin wave due to the crystal.A little extra thought
Wonder why oscillators pull so much current? You are charging and discharging the capacitance in the oscillator circuit 20 million times per second. Also, for all the clock cycles many transistors in your circuit do the same. if you do not need speed, a 32KHz oscillator costs very little in power on microcontrollers.Let me know if I can be more clear.
From Wikipedia:
An oscillator crystal has two electrically conductive plates, with a slice or tuning fork of quartz crystal sandwiched between them. During startup, the circuit around the crystal applies a random noise AC signal to it, and purely by chance, a tiny fraction of the noise will be at the resonant frequency of the crystal. The crystal will therefore start oscillating in synchrony with that signal. As the oscillator amplifies the signals coming out of the crystal, the signals in the crystal's frequency band will become stronger, eventually dominating the output of the oscillator. The narrow resonance band of the quartz crystal filters out all the unwanted frequencies.