This is a common misconception.
Teachers teach students in the classroom as part of regular instruction for 3/4 of the year. The vast, vast majority of teachers do a lot of work both during the summer and on evenings and weekends to prepare for that teaching, including lesson planning, grading, teaching summer school, supervising extracurriculars, and even coaching school sports in many cases.
And any teacher getting hired now (or, in fact, within the last few decades) doesn't get what you'd think of as an "unassailable pension", at least not in most places. I think that NY State would generally be considered to be one of the more teacher-friendly places, and the last of the "Tier I" retirees here—those whose pensions cover basically their full final salary—are already either retiring or on their way to it.
The idea that teachers are overpaid is bullshit propaganda.
Very much so.
Statistics from the Census [1]:
So, not only is this close to median income, but 60% of workers have to have two people to achieve it. And teachers work 3/4 of the year (annual amortized salary would be much higher), and have unassailable pensions.The reasons for this, of course, are that 3% of all workers are teachers, school board elections are held on odd (or off) years with low turnout, and controversial legislation is put in the docket on those elections. It is money for votes and it has been for a long time.
[1] https://www2.census.gov/ces/wp/2019/CES-WP-19-19.pdf