Examine, investigate and ask thoroughly… (Deuteronomy 13:15)
Justice is taken very seriously by the Torah and many mitzvos address the courts and how they should endeavor to try cases fairly. Here, the judges are told to thoroughly examine the witnesses in order to ensure that the charges against the accused are accurate. This is reflected in the very first mishna in Pirkei Avos (1:1), which enjoins the judges to be exacting in their work.
The witnesses were grilled very thoroughly about the time, place and nature of the crime they observed. For example, “I saw Bob worship an idol” is insufficient. The judges would want to know the exact date and time, the location, what idol Bob served, the nature of the service he performed and more. In a murder trial, they might ask what the victim was wearing, what the accused was wearing, or about the soil conditions where the event occurred. If the witnesses contradict one another, their testimonies are discounted.
The reason for this mitzvah is the importance of thorough courts in society. Courts that work hard to ensure that justice is served are necessary for a society to endure. Not only that, the thorough examination of witnesses can often mean life and death to the person standing trial!
This law always applies in civil cases. For capital cases, it only applies in Israel at a time when there is a functioning Sanhedrin. This mitzvah is discussed in the Talmud in the fifth chapter of tractate Sanhedrin, beginning with the mishna on page 40a. It is codified the Mishneh Torah in the first chapter of Hilchos Eidus. This mitzvah is #179 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos; it is not listed among the mitzvos that can be fulfilled today in the Chofetz Chaim’s Sefer HaMitzvos HaKatzar.