I think the most important thing is that you set expectations prior to the trip. Everyone should be on the same page about the planned route, schedule, meals, etc. Of course, planning is different from doing, so you need a social structure to determine how to handle disputes en route.
One option is to pick a leader who is experienced both with backpacking and handling disagreements. Everyone knows to go to the leader to mediate problems. This gives the group structure and alleviates tensions between the rest of the group. This is best in groups where there's a clear choice (one person much more experienced, adults leading a group of teens, etc.) both so nobody's feelings get hurt and so their decisions are respected.
Another option is to rotate leadership. Let one person lead the trail on day one, another on day two - everyone gets time in the hot seat. This is best when everyone has similar levels of experience. You could also do this with smaller tasks, e.g. have a troop leader who is ultimately responsible but let the kids take turns navigating.
If your group is large enough, split up into sub-groups. For example, on one trip we switched canoe partners each day. So even if we got annoyed with someone, we would only have to put up with them for a day.
Finally, give people room for downtime. Maybe it's just the introvert in me, but after spending a few days in close quarters with other people and feeling smelly, everything can get on my nerves. Sitting quietly on a rock by myself for a few minutes does wonders to recalibrate.