Adam Smith (1776) described how each individual, working solely for their own self-interest can interact, in a fair marketplace, to maximize the benefits for everyone. The unintentional, “invisible hand” of the market converts selfish actions toward a greater good if the conditions are right. The key condition is the rule of law.
Without clear, enforced laws, to prevent theft and to ensure property rights, the free-market economic system breaks down. Of necessity, the laws must be fair. If they are not then they will be violated, and in general it helps to minimize the number of laws people have to keep track of. People are free to do whatever they want, as long as they follow the law.
Similarly the classroom. Students need clear rules. Rules that establish the proper way to interact with their peers, and rules that protect individual rights to property and autonomy. While we hope they subscribe to their natural altruism, and indeed encourage its development, there need to be clear laws that they all can agree on. This is why we spend a lot of time at the start of each year be developing our set of rules and classroom constitution. To gain the maximum legitimacy, students develop the rules themselves, with some guidance, and establish ways of enforcing them. In my classroom, for example, we also dedicate time twice a week for a sort of legislative/judicial session, designed to deal with issues and problems that crop up.
But the reason for setting these limits is to allow freedom: freedom to learn.