What yield to maturity is trying to summarize
Yield to maturity is the internal rate of return for a simplified hold-to-maturity bond scenario. It combines periodic coupon cash flows and the difference between current price and final redemption value into one annualized figure.
That summary is powerful, but it can also be misunderstood. Yield to maturity is not the same as coupon rate, and it is not guaranteed realized return. It is the discount rate that makes the model's cash flows fit the entered price under the stated assumptions.