Medieval people totally believed in rule of law. They were often making up the law as they went, but they really did believe that following the law was very important. Trials were part of this.
Although modern society has (understandably) a rather negative view of trial by ordeal, it was based on the idea (that made perfect sense in the Middle Ages) that God knew who was innocent and who guilty, so they just had to get God to reveal His judgment.
Most obviously, in a trial by combat, the accused and the accuser would each have a champion who would fight for them. The winner clearly was meant to win. In trial by water, the accused would be dunked in a big tub. If they floated, it meant they were guilty, because the water rejected them. If they sank, they were innocent and had to be pulled out fast. In a trial by fire, one would be burned (either by taking hold of a hot iron or by actually running through fire). The burn, cleaned and bandaged, would be examined in a week to see if it was healing nicely, in which case the accused was innocent, or getting all infected, in which case he was guilty.
Medieval people certainly recognized the ambiguities possible in all this. Everyone knew or had heard of cases where the obviously guilty party got off because he had a better champion to fight for him. How nicely a wound was healing was certainly a matter of discussion. Because of this, trials by ordeal were actually fairly rare. Judges, who could be the local landlord, the local count, the sheriff in England, even the king, would hear witnesses and examine evidence. But their principal role was not to rule definitively on guilt or innocence but rather to get the disputing parties to come to an agreement. A major part of all medieval legal cases was having a big discussion. The only sure way to get a definitive judgment was for one of the parties not to show up.
Curiously from a modern point of view, often an accused person would request trial by ordeal. However, trials by ordeal were actually carried out far less frequently than they were proposed. The accusers seem to have often worried that, if someone was willing to suffer a major burn (the most common kind of trial by ordeal) to demonstrate innocence, he might really be innocent. More discussions would follow.
Not only people were tested by fire--so were relics. If one had acquired a bone and were unsure whether it was a saint's or some old pig bone, one threw it into the fire (after a suitably reverent ritual). If it hopped out, it was a saint's. It all made sense.
To do any of this, of course, one needed to be sure that God was going to be passing the real judgment. Thus one needed priests and blessings and oaths. However, in 1215, eight hundred years ago this year, the church officially got out of the ordeal business. Church lawyers felt that trials by ordeal "tested" God, forcing Him to reveal His judgment, which is actually against the Bible. Without priests, it was a lot harder to do a decent ordeal.
More discretion thus went to the judges and, in England, juries. Originally "juries" had not been those who decided guilt or innocence but rather witnesses. The word comes from the Latin iurati, those who have sworn to tell the truth. In fact, originally "trial by jury" was a form of ordeal, getting a dozen friends to all swear on holy relics that you were innocent. If you weren't, usually about halfway through someone would break and blurt out the truth rather than perjure himself.
In late medieval England, jury trials started taking on the form they have now in England and the US, local people assembled to help the judge make decisions based on evidence and witnesses. The main difference is that now we want the jurors to know nothing about the case ahead of time; then, the jurors came in extremely well-informed already. (By the way, jury trials have nothing to do with Magna Carta, which does not mention them. I'll discuss Magna Carta another day.)
Trials by ordeal continued at a low level, as long as one could find a cooperative priest, which became harder and harder. In late medieval England, some people tried to get out of their obvious guilt by insisting on a trial by ordeal, knowing that that could mean no trial at all. In response, judges took to making them lie down, putting a board on top of them, and starting to pile on stones, while asking if they had reconsidered what kind of trial they wanted. At this point, most suddenly wanted a trial by jury.