Judges and officers you shall appoint… (Deuteronomy 16:18)
Every Jewish community is responsible to appoint judges and officers in order to uphold Torah law within their community. This court is called a beis din and we find local batei din (the proper plural) in Jewish communities worldwide to this very day. In many places, if the litigants agree to take their dispute to beis din, the beis din’s ruling is legally binding by secular statute.
Judges appointed to beis din should have impeccable credentials. The smallest beis din consisted of three judges; larger batei din were 23 judges and the Supreme Court of Jewry, the Sanhedrin, was 71 judges. When a matter was too much for a local beis din to handle, they would kick it upstairs to a higher court.
Other officers, called shotrim, were roughly equivalent to policemen. Their job was to walk the beat, keep the peace, and just generally keep an eye on things, making sure the laws were being observed.
The reason for this mitzvah should be apparent: we’re big fans of orderly societies and we’re not too crazy about anarchy, chaos and lawlessness. The mere presence of a functioning legal system is enough to get most people to behave relatively well. Being “forced” to do so is a form of behavior modification; we get used to behaving properly towards one another out of fear of the authorities but being good to one another eventually becomes ingrained within us.
The commandment to have a Sanhedrin only applied in Israel at a time when we had the original semicha (ordination). The original semicha was conferred by Moses to Joshua and the 70 elders and every member of the Sanhedrin was likewise ordained. (Our current ordination does not represent this unbroken chain of transmission.) The Sanhedrin could only judge capital cases when the Temple was standing. Local communities are obligated to have a beis din even today, so long as there are people qualified to serve. If learned, upright members of the community exist but refuse to step forward to fulfill this task, it is a serious sin of omission on their part.
This mitzvah is discussed in the Talmud in the first chapter of tractate Sanhedrin and in Makkos (7a). It is codified in the Shulchan Aruch in Choshen Mishpat 1. This mitzvah is #176 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.