APY accounts for interest earning interest during the year. A rate of 5% compounded monthly works out to an APY of 5.12%, because each month's interest is added to the balance and earns interest itself.
The formula is APY = (1 + r ÷ n)ⁿ − 1, where r is the stated annual rate and n is the number of compounding periods per year. The more often interest compounds, the bigger the gap between the rate and the APY, though the difference between daily and monthly compounding is small.
Banks advertise APY on deposits because it's the higher number. Lenders advertise APR on loans for the same reason. The Truth in Savings Act requires banks to disclose APY.