You shall do to him as he conspired to do… (Deuteronomy 19:19)
Here’s an interesting mitzvah: if false witnesses conspire to frame an innocent person, they are subject to the penalty they sought for the accused. This rule applies whether they attempted to have the innocent party fined, lashed or even executed. What’s surprising is that the false witnesses are only put to death if their plot is discovered before accused is executed. This is because the Torah says “do to them as they planned to do,” not “as they did.” (See Talmud Makkos 5a.)
The way the witnesses are discredited is as follows: A second pair of witnesses comes and testifies that the first pair couldn’t possibly have seen the thing they testified about. Why not? Because the first pair was with the second pair at the time. (It doesn’t have to be a pair. It could be 20 or 50 or 100. Two is the minimum.) In this matter, the Torah gives greater credibility to the second pair, but only to say that they first pair wasn’t present at the event in question. If the second pair argues about the details of the accused’s case, they have no advantage over the first pair.
The reason for this mitzvah is to discourage false testimony; it can really come back to bite a liar! The world relies upon truthful testimony; without it, society would crumble.
The Sefer HaChinuch says that he heard a good explanation as to why the second pair of witnesses is believed over the first. The reason is that we have a principle that credible witnesses are believed. When A and B testified against the innocent man, they were believed. Now that C and D testify against A and B, they, too, are believed.
This mitzvah applies in Israel at a time when we have an ordained Sanhedrin. It is discussed in the Talmud in tractate Baba Kama on pages 72b-73a; it is also the very first topic discussed in tractate Makkos. It is codified in the Shulchan Aruch in Choshen Mishpat 38. This mitzvah is #180 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.