Programmers make more than teachers, so someone that is any good at programming is better off being a programmer than a teacher. Which leaves people who don't know how to program to teach high school kids to program.
Which is why everyone is a "self taught" programmer.
Imaging if you took everyone that posts to Hacker News about how they were the only person in their school that knew how a computer worked and they did all sorts of hacks and had all sorts of fun subverting authority and you went back in time and you gave them a knowledgeable mentor (read: teacher) how much better would they be at programming now?
It's 2015 and we don't have those teachers in our schools. What we have are Math teachers that are being told "We have to have a Computer Science class and we heard that programming is like math, so you're going to be teaching Computer Science next year. Go take a Java course."[0]
Also, unions are not keeping the pay scales the way they are. Texas does not have unions. Texas does not have tenure. Texas still has "lock step pay scales". Unions are not the problem.
Private schools pay teachers less than Public Schools. Private Schools don't have unions. Unions are not the problem.
I don't know what the problem is. I think it has something to do with there being very little respect or prestige for the teaching profession among tax payers (or anybody, really). But the problem isn't unions. If unions were the problem, then the problem wouldn't exist in places where there are no unions.
[0] 100% serious. I had a training this summer where 6 of the other 7 teachers were Math teachers that were told at the end of the year that they would be teaching AP Computer Science and were sent off to take their first ever Java course over the summer.