Diacetyl is a fermentation byproduct that tastes and smells distinctly like butter or butterscotch — produced by yeast early in fermentation as a natural intermediate compound, and normally reabsorbed and cleaned up by healthy yeast later on, if fermentation is given enough time and, often, a deliberate warm-up near the end.
The "rest" that's really just patience with a warmer nudge
A diacetyl rest — letting fermentation temperature rise a few degrees for the final days of primary fermentation, particularly common with lager yeast — speeds up that natural reabsorption process rather than doing anything fundamentally different from what a longer, patient fermentation at a stable temperature would eventually accomplish on its own. Rushing a beer to packaging before yeast has had time to clean up diacetyl is the single most common reason it shows up in a finished, bottled beer.
Where it's a flaw and where it's genuinely traditional
Diacetyl above a low threshold reads as a clear off-flavor in almost every style on this site, particularly clean lagers where it has nowhere to hide — but a small amount is traditionally tolerated, even expected, in certain English ale styles historically fermented with strains that produce a bit more of it naturally. Knowing which category a given style falls into matters before treating any diacetyl presence as an automatic brewing mistake.