Another interpretation: this is a warning to the judge not to hear from one litigant until his opposing litigant comes with him, as it is said, "Then both men shall stand" (Deuteronomy 19:17). Abba Hanan says in the name of Rabbi Eliezer: it comes to include the oath imposed by the judge, that it be answered with "Amen," for if you answer "Amen" after him [falsely] you commit a false oath. "Do not join your hand with a wicked man" (Exodus 23:1) — one says to another: So-and-so owes me two hundred zuz and I have one witness; come and join with him so that I may collect what is mine, and you take a maneh and I a maneh; therefore it is said, "Do not join your hand." Or one says: You know about me that even if a man gave me all the money in the world I would not lie; now, So-and-so owes me and I have one witness; come and join with him so that I may collect what is mine; therefore it is said, "Do not join your hand with a wicked man to be a witness of violence." Thus the scrupulous people of Jerusalem would act: none of them would go to a banquet until he knew who was going with him, and none would sign a divorce document until he knew who was signing with him. Rabbi Natan says: "Do not set a wicked man as a witness, do not set a violent man as a witness" — to exclude the violent and the robbers, who are disqualified from testimony, as it is said of the witness of violence, "He shall not stand" [a violent witness]. Abbaye said: a witness proven false [by alibi] is disqualified retroactively; from the moment he testified he was wicked, and the Torah said, "Do not set a wicked man as a witness." Rava said: he is disqualified only from that point onward, for the conspiring witness is a novel ruling [hiddush], since here are two against two — what did you see to make you believe these rather than those? And you have nothing in it except from the time of its novelty onward. And the law is according to Abbaye in [the cases summarized by the mnemonic] ya'al kegam.
Hearing Both Sides and Refusing the Dishonest Witness
Yalkut Shimoni on Torah 352:5
דָּבָר אַחֵר, הֲרֵי זֶה אַזְהָרָה לַדַּיָן, שֶׁלֹּא יִשְׁמַע מִבַּעַל דִּין עַד שֶׁיָּבוֹא בַּעַל דִּינוֹ עִמּוֹ, שֶׁנֶּאֱמַר (דברים יט, יז) "וְעָמְדוּ שְׁנֵי הָאֲנָשִׁים". אַבָּא חָנָן אוֹמֵר מִשּׁוּם רַבִּי אֱלִיעֶזֶר, לְהָבִיא שְׁבוּעַת הַדַּיָּן שֶׁתְּהֵא (נֶאֱמָן) [בְּאָמֵן], שֶׁאִם אַתָּה עוֹנֶה אַחֲרָיו אָמֵן עוֹשֶׂה אַתָּה שְׁבוּעַת שָׁוְא. אַל תָּשֶׁת יָדְךָ עִם רָשָׁע, אָמַר לוֹ, אִישׁ פְּלוֹנִי חַיָּב לִי מָאתַיִם זוּז וְלִי עֵד אֶחָד, בּוֹא וְהִצְטָרֵף לוֹ עַל מְנַת שֶׁאֶקַּח אֶת שֶׁלִּי, וְאַתָּה טוֹל מָנֶה וַאֲנִי מָנֶה, לְכָךְ נֶאֱמַר אַל תָּשֶׁת יָדְךָ. אָמַר לוֹ. יוֹדֵעַ אַתָּה בִּי שֶׁאֲפִלּוּ נוֹתֵן לִי אָדָם כָּל מָמוֹן שֶׁבָּעוֹלָם אֵינִי מְשַׁקֵּר, וַהֲלֹא פְּלוֹנִי חַיָּב לִי וְלִי עֵד אֶחָד, בּוֹא וְהִצְטָרֵף לוֹ עִמּוֹ עַל מְנַת שֶׁאֶקַּח אֶת שֶׁלִּי. לְכָךְ נֶאֱמַר אַל תָּשֶׁת יָדְךָ עִם רָשָׁע לִהְיֹת עֵד חָמָס. כָּךְ הָיוּ נְקִיֵּי הַדַּעַת שֶׁבִּירוּשָׁלַיִם עוֹשִׂים, לֹא הָיָה אֶחָד מֵהֶם הוֹלֵךְ לְבֵית הַמִּשְׁתֶּה עַד שֶׁיּוֹדֵעַ מִי הוֹלֵךְ עִמּוֹ, וְלֹא הָיָה חוֹתֵם בְּגֵט עַד שֶׁיּוֹדֵעַ מִי חוֹתֵם עִמּוֹ. רַבִּי נָתָן אוֹמֵר, אַל תָּשֶׁת רָשָׁע עֵד, אַל תָּשֶׁת חָמָס עֵד, לְהוֹצִיא אֶת הַחַמְסָנִין וְאֶת הַגַּזְלָנִין שֶׁהֵן פְּסוּלִין מִן הָעֵדוּת, שֶׁנֶּאֱמַר "לֹא יָקוּם", עֵד חָמָס. אַבַּיֵּי אֲמַר, עֵד זוֹמֵם לְמַפְרֵעַ הוּא נִפְסָל. מֵהַהוּא שַׁעְתָּא דְאַסְהִיד הֲוָה רָשָׁע, וְהַתּוֹרָה אָמְרָה אַל תָּשֶׁת רָשָׁע עֵד. רָבָא אֲמַר, מִכָּאן וּלְהַבָּא הוּא נִפְסָל, עֵד זוֹמֵם חִדּוּשׁ הוּא, דְּהָא תְּרֵי וּתְרֵי נִינְהוּ מַאי חֲזֵית דְּצָיְיתֵת לְהָנֵי, צָיֵת לְהָנֵי, וְאֵין לְךָ בּוֹ אֶלָּא מִשְּׁעַת חִדּוּשׁוֹ וָאֵילָךְ. וְהִלְכְתָא כְּוָותֵיהּ דְּאַבַּיֵי ביע"ל קג"ם.