What does the rectifier do in a crystal radio?
It's called an envelope detector. The diode prevents the base frequency from going negative. The original signal had an average value of 0. If you fed this through a low-pass filter (aka a capacitor), the output signal would be 0. With the diode in place, the signal can never go negative and now if you average out your signal using a low-pass filter, you get a slowly varying signal (relative to the base frequency) that no longer has an average of 0. This signal is now useful for the speaker.
https://en.wikipedia.org/wiki/Envelope_detector
The diode demodulates the AM radio signal. To demodulate (recover the audio signal) from an AM radio signal all that is needed is to retrieve the amplitude of the signal:
Source: this article
That's what the diode does.
It blocks the negative part of the wave but lets the positive part pass. This together with the capacitor recovers the audio signal.
Your example does not contain a resistor and a capacitor, they are present though. The headphones can only work on audio signals so it basically performs the same function (a low pass filter) without needing those components.
Here's a physical description that might help intuitively -
Hum a 1kHz tone into a microphone, and broadcast it on a 100kHz AM carrier.
At your receiver, ideally you would like the earpiece diaphragm to alternately displace outwards and then displace inwards every millisecond, and for decent sound quality maybe you'll settle for having it alternately displace outwards and then rebound to equilibrium every millisecond.
Without the diode, your earpiece diaphragm will attempt to vibrate at 100kHz strongly for half a millisecond, and then more weakly or not at all for the next half millisecond. Even if the earpiece responds slightly at that frequency, your ear will not and you will hear nothing.
With the diode, for half a millisecond your earpiece diaphragm will be nudged outwards every 10 microseconds (5 microseconds at a time). Even without any extra filtering capacitors and thus with all those 5 microsecond gaps in the current, 500 straight microseconds of having the diaphragm continually nudged in the same direction at such close intervals should accomplish some displacement. That is, the mechanical characteristics of your earpiece will probably accomplish some of the actual demodulation when operating on a rectified signal. When operating on an unrectified signal however, those same mechanical characteristics will demodulate it to something close to silence.