That said, I'm not sure I'd agree with Mike McShane that the craziest thing here is that gym teachers get paid more than math teachers. I know that it's easy to pick on gym teachers; and I certainly had some who lived up the stereotypes. But I'm not sure we should blithely assume gym teachers should necessarily be paid less than math and science teachers. Presumably, schools employ gym teachers, and states and schools mandate that students complete physical education credits, because our society believes there's some social value in what these courses teach--and by extension the work gym teachers do. (I suspect that value may be up for debate, but if so we should start by asking why schools offer or states mandate these courses in the first place.) Nor should we necessarily assume that "The labor market value of a math teacher, that is, what they could make if they decided to do something else, is significantly higher than that of a gym teacher." Having certification or even a major in math doesn't necessarily mean that a math teacher is qualified for in-demand or higher-paying STEM jobs. There are a surprising number of hard science Ph.D.s with lousy career prospects. And gym teachers may have non-academic skills and good old boy connections that--particularly in a small town or rural context--may give them more career options outside of a school than their math-teacher colleagues.
More broadly, the relative job market prospects of different teachers, the demand/supply for their skills, and the impact they have on students are questions that are both empirical and that vary with context. There are almost certainly circumstances where it makes sense to pay a really great gym, or art, or music teacher more than some math teachers get paid. The real problem is that our current system doesn't take issues of value-added or demand/supply into account at all.