Agree with thine adversary quickly, whiles thou art in the way with him; lest at any time the adversary deliver thee to the judge, and the judge deliver thee to the officer, and thou be cast into prison. Matthew 5: 25
In the east, judges were not stationed in every town or city. If someone had a legal matter that had to go before a judge, they usually had to travel a distance. Once the date for court had been set, the two opposing parties, their lawyers, and the witnesses would all start on the journey together. While they were 'in the way', they would be able to discuss the case, and come to realize that going to court would only be wasteful to both parties. A compromise could then be reached, and then only the lawyers would have to continue the journey, so they could inform the judge the case was settled 'out of court'. Going to court was usually considered to be a shameful thing, which is why most cases were settled 'in the way'. It also explains why there was not much work for judges.
The George M. Lamsa translation of the ancient Peshitta text for this verse in Matthew is easier to understand:
Matthew 5: 25 -- Try to get reconciled with your accuser promptly, while you are going on the road with him; for your accuser might surrender you to the judge, and the judge would commit you to the jailer, and you would be cast into prison.
Jesus was saying to avoid going before the judge if at all possible. God's Word addresses this subject clearly and concisely in the book of Romans.
Romans 12: 18 -- If it be possible, as much as lieth in you, live peaceably with all men.
Jesus was advocating a win-win situation instead of win-lose.