In D&D, there's a spell called zone of truth. It forces anyone within the zone to tell the truth. Pretty useful in a courtroom, right?
Then I took a look, and noticed someone with sufficiently strong willpower could overcome it, that all affected by it were aware of it, and that it's a divine spell that only clerics and paladins can cast. So it naturally has its limitations.
And then I thought, "Well, what if it's contingent on a swearing-in?"
"Do you swear to tell the truth, the whole truth, and nothing but the truth, so help you [Tyr, god of justice]?" "No. I don't worship [Tyr]." So they have to find a priest of the appropriate clergy to swear him in. Gods help you if he's a follower of Baenvar Wildwanderer, the gnomish god of trickery and pranks...
What if a priest of the god of justice began to notice that the courts were more interested in satisfying the letter of the law, rather than its spirit (i.e. justice)? He might start claiming he's cast the spell, and psychosomatically everyone believes it, as why would he lie? But when someone is accused of some crime, and it would be a huge miscarriage of justice even if it were legally sound, and he told this person and his witnesses he could lie freely...