Normally the temperature gets colder as you go higher in altitude. But on cold, calm nights, cold air will settle near the surface since cold air is heavier than warm air.
In the meantime, a lack of winds will prevent the air from mixing. The pattern also usually creates ground fog.
When the sun comes up, it will start to warm the air above the fog layer, creating an inversion -- it's actually warmer in higher altitudes than at the ground.
That helps further trap the cold air, and everything else in it, near the surface -- including pollutants. That's why air quality suffers during inversions and usually leads to burn bans.