The NMDA receptor functions as a molecular coincidence detector, recognizing the confluence of strong depolarization and synaptic input at a specific synapse.
Hebbian learning is best summarized as "neurons that fire together, wire together": synapses become stronger between neurons that are commonly co-active. It allows neurons to discover correlations.
Because NMDA receptors recognize the combination of depolarization and synaptic input, they serve as a signal of whether two neurons have "fired together" and so control whether they "wire together".
The NMDA Receptor
The NMDA receptor is both a ligand-gated ion channel and a voltage-gated ion channel. The voltage gate is relieved by depolarization, while the ligand gate is relieved by the binding of glutamate (the G in MSG). Like the Theodosian Walls of Constantinople, all gates must be open to allow passage (Turks with bombards excepted, in both cases).
Unlike other ion channels, the NMDA receptor's primary function is not to pass a current and change the membrane potential. The NMDA receptor is a non-selective cation channel, meaning that it allows through any positive ion. Most importantly, that means that the NMDA receptor allows calcium to flow down its electrochemical potential and into the cell.
This is critical because calcium is a major second-messenger molecule, meaning that it activates, deactivates, and modulates the internal biochemical processes of the cell. In synapses, this includes activating a variety of mechanisms that increase the strength of a synapse.
This increase in strength, then, occurs whenever the cell is strongly depolarized AND it receives input. Why might this be useful? Let's first talk about Hebbian learning.
Though originally developed as a model of neural behavior, Hebbian learning has proven to be useful for some kinds of machine learning and statistical inference, just like Boltzmann machines and artificial neural networks.
In a Hebbian learning model, the synapse from a neuron A to a neuron B increases in strength whenever the activation of neuron A causes neuron B to fire an action potential.
This of course means that the next time neuron A fires, B is even more likely to fire, and so the strength increases in a positive feedback loop. If Hebbian learning is paired with homeostatic plasticity, other synapses will decrease in strength to compensate, and so the neurons will become correlated.
This combination is sufficient to train a simple neural network model, the Hopfield Model, which can store and recall patterns of input, even when that input is corrupted by noise.
Putting It Together
The NMDA receptor causes increases in synaptic strength whenever a neuron A depolarizes a neuron B sufficiently, just as is needed to implement the Hebb Rule! It's a match made in heaven and a victory for theoretical neuroscience!
Well, not exactly.
First, single synapses don't usually cause sufficent depolarization, by themselves, to relieve NMDA block. The experiments that showed these effects involved "tetanic stimulation", or the application of rapid intense depolarizations for extended periods. These circumstances hardly ever arise physiologically.
Second, the NMDA receptor can also activate synaptic depression. That is to say, if the influx of calcium is small, but still non-zero, the synapses decreases.
There are some models that resolve this difficulty.
For example, active processes like back-propagating action potentials or dendritic spikes might be the main drivers of the depolarization, opening the voltage-gate for all channels. In this way, only synapses where glutamate was recently released have strong calcium influx, and any synapses activated later will have the small calcium influx necessary to cause depression.
The precise details of this model remain to be worked out, since it involves handling both biologically-realistic compartment models and active current processes.