Programs such as Honors, AP, electives, etc., are the cheapest way for any student -- regardless of socio-economic background -- to receive high-quality education. Without those programs offered at public schools, I suspect that even more upper-middle class families would transfer to private schools or schools in the suburbs.
Consider sports electives: were they not offered at public schools, the only option would be club programs, often costing thousands per year. At a public school, somewhere around $50 is all that's needed for a year's worth of participation, with coaching that can be comparable to exclusive club teams, and scholarships available for even that amount.
edit: Also, because AP programs are standardized across the country, a student that passes AP Statistics at any school will have the same chance of getting college credit at any school that offers it. This levels the playing field a lot.