This thread has become quite hostile, which is a shame because this is an important issue. Feeling valued, and having effort and accomplishments recognised/rewarded/given opportunities, is vastly important to children. (How many adults would stay in a job if they were working hard, achieving, but not being recognised, while others were getting recognition?) Yes, I know it's been done to death, but when this sort of thing happens, it's so upsetting that people need to vent, and why shouldn't they do so here? Anyone who is fed up of the subject doesn't need to read it.
I've seen favouritism in two of the schools my DC have attended, but not in the third, so I don't think it's inevitable (and within the schools, there are teachers who don't seem to do it). To the teacher who says he/she chooses the quiet, well-behaved, undemanding, hard-working children, I believe you, and wish you worked in my DC's school. In my DC's school, this is precisely the sort of child least likely to be chosen.
I think there are a few things going one. Some teachers (not all) choose the children most likely to protest if they're not chosen. That tends to be the most assertive, confident ones, who aren't afraid of being seen as rude to adults. The teachers aren't necessarily conscious of doing this. My DS is extremely compliant, polite and afraid of being told off/drawing attention to himself. Teachers know (again, not necessarily consciously) they can leave him out, without there being any fuss for them to deal with (he'll go home and cry, but they don't see/deal with that, and don't believe me when I tell them). This is probably happening more and more, as teachers have more pressures put on their time, and need to get things done as quickly, and with as little fuss, as possible.
I've tried to teach my DC to stand up for themselves, and challenge unfairness, but they do this in such a quiet, ultra-polite way, that the teachers just fob them off with, 'I had a reason for choosing her/I chose carefully/maybe next time'. They've now learned that there isn't any point in trying to do this. I've also pointed it out to teachers several times, but am similarly fobbed off (I have a similar personality to my children!).
The other thing (and there's research evidence to support this) is that people tend to mistake confidence for competence, particularly where leadership roles are concerned. There's a cultural stereotype that you need to be dominant and competitive to be a good leader. Actually, introverts make good leaders because they listen to others' ideas and are more likely to compromise (read 'Quiet', by Susan Cain). They tend to be more concerned with getting the job done in the best way, rather than having people do what they say. (Of course, this is a generalisation too, and confident children can have good leadership skills, but the point is, at the moment, there is a belief in a lot of schools that the socially confident children are the only ones who will make good leaders, and the quiet children aren't getting a chance to show what they can do). I've seen my DS's leadership skills at scouts, where he is given a chance. I just wish the teachers could see him there. Time and again, on threads like this, parents of quiet children have said, 'When my child finally got a chance, everyone was amazed at what he could do'. The parent wasn't amazed - they'd known what their child was capable of all along. My DS has nearly finished primary school now, and has never been chosen to be a group leader in a classroom activity/have a leadership role in the school. The teachers have a certain impression of what he's capable of, and they vastly underestimate him.
These things are important because soft skills (leadership, public speaking, talking to different sorts of people) are as important as qualifications. Where academic subjects are concerned, schools seem to focus their resources on those who struggle but, where soft skills are concerned, they give them to those who already have the skills (as if the purpose of school is a show-case for skills children already have, rather than a place of education for all). The children who most need these experiences are the ones least likely to be given them. It's also true that this is a socio-economic issue, as children whose parents can afford out of school activities are more likely to have confidence and social skills (and therefore are given more opportunities to develop these in school). The Matthew effect in action.
Another thing that happens is that, once a child gets themselves noticed, they are more likely to be chosen in the future because teachers think of them. For example, my DD got a higher grade in an exam (and consistently higher marks in class - they're friends so they compare their marks) than another girl, but the other girl got the end of year award for that subject. I can only assume this is because she's on sports teams and in drama productions, and is therefore more 'visible' within the school. The award was supposed to be for excellence in that subject though, so anything else the girl did within the school shouldn't have been relevant. Again, I'm not claiming anyone sits down and thinks, 'We know her, so let's choose her'. She is just more visible, and her name is known.
Teachers do have enormous pressures on them, but this is something that is so easily fixable, and I think that's why parents get so frustrated. It doesn't take any resources, just a bit of thought, communication with other teachers about who had done things previously, and (perhaps most importantly) willingness to challenge stereotypes about different personalities.