A simple yield spread compares two single numbers and quietly assumes a flat curve. The Z-spread instead discounts each cash flow at the matching spot-rate plus a constant increment, then solves for the increment. That makes it robust to curve shape.
Because it uses the whole zero-curve, the Z-spread is the right measure when the curve is steep or inverted, where a naive spread to a single benchmark can mislead by tens of basis points. It still ignores embedded options, which is what option-adjusted-spread adds.
Example: a 5-year bond prices at 97.80. Discounting its cash flows at spot rates of 4.60%, 4.45%, 4.35%, 4.32% and 4.30% plus a constant z, the price matches at z = 142 basis points. Its simple spread to the 5-year Treasury is 137, so the curve shape is worth 5 basis points.
Related: option-adjusted-spread, spot-rate, zero-curve, credit-spread-bonds, bootstrapping