I split this out because it seems like a pretty interesting topic on its own merits.
I'm personally a big free market guy, but the points brought up here do give some good examples of where the free market doesn't always give us the best answer (or maybe the lack of a free market doesn't give us the right answer if one wants to point to teacher's unions as the cause of standard salaries for teacher as opposed to merit pay based on performance).
It seems like a lot of what it boils down to is that there are a lot of non-monetary items at play that impact the equation as well. We are all selfish creatures, although each of us is selfish in different ways. (NOTE: Selfish doesn't imply anything bad, it just that we place personal value in things that we want or cherish beyond just money). For instance, someone who goes into the military may value the concept of serving their country to a high degree, so their selfish desire to do so (again, not a negative connotation) makes the lower salary acceptable. There might also be elements of glory or admiration from others that add to the value of that job. That being, said, I am fully in favor of paying them fairly ... this only goes to explain why people might still enlist absent a good salary.
Some of the same elements are in play for teachers, although the values might be a bit different. The desire to serve the public or to work with children is at play. The desire for lots of time off might add to it. And, yes, some people that go into teaching just aren't very bright, so they don't have the option of chasing after higher paying jobs. (I have lots of teachers in my family and as close friends, so I'm quick to say that "not very bright" group is an unfortunate minority, because all the teachers I know personally are brilliant

).
Executive salaries generally are earned when the companies are successful (as mquast noted, they are the cream of the crop, and their value is dictated by how well they can do their jobs). However, I do think that are some very real problems in the equation with executives making a truckload of cash for failing. I have seen way too many execs get fired for sucking at their jobs, and then getting a couple million dollars on their way out the door. That's mostly due to our litigious society (it's basically a pay-off to not sue for any number of likely bogus, but still potentially costly, matters) as well as a bit of a modern old boys and girls club. They look out for each other as they might need a cushy job in the future, and you never know when you will run into each other again. I guess the only answer to this problem is for Boards to be stronger and more independent of the execs themselves. This part is getting a bit better in the wake of Enron and all of the additional scrutiny on corporate America that resulted (along with trillions of dollars of completely useless regulations on corporations in the form of Sarbanes-Oxley).
I unfortunately could go off on any number of rants from here, so I will just stop there....