An ordeal was originally a verdict. The word meant a judgment handed down, and the judge was believed to be God.
Old English ordal or ordel meant "trial by physical test," and literally "judgment, verdict." It goes back to Proto-Germanic uz-dailjam, "a portioning out." The first part, or-, means "out." The second part is related to deal, in the sense of dealing out shares. An ordeal was what got dealt out to you.
The practice settled guilt when ordinary proof was lacking. In medieval England the two standard forms were cold water and hot iron, each preceded by a liturgy led by priests. In the water ordeal, the accused was dunked in a cistern. Sinking meant innocence, because the water had accepted them, and floating meant guilt. In the iron ordeal, the accused carried a heated iron a set number of paces. The hand was bandaged and checked three days later, and festering meant guilt.
The end came from the Church. In 1215 the Fourth Lateran Council withdrew priests from administering ordeals. That left English courts needing another method of proof, and they turned to the jury. Etymonline notes that ordeals were abolished in England under Henry III.
The word nearly disappeared with the practice. Middle English used it rarely, mostly in Latin texts, though Chaucer wrote "by ordal" in Troilus and Criseyde. The modern word may be a 16th-century reborrowing from Medieval Latin or French. William Lambarde's A Perambulation of Kent, published in 1576, refers to "iudgments by the Ordale."
The modern sense, any severe trial of courage or patience, is where the sources disagree. Etymonline dates it to the 1650s. Word Histories finds a transitional use in 1687 and a clear one in the Ipswich Journal of 1748, which mentions "the Ordeal of a Committee."
Other Germanic languages kept the legal meaning. German Urteil and Dutch oordeel both mean judgment, and German has generalized the word to any judicial decision. English even met the German word again: value judgment, recorded from 1889, is a loan-translation of German Werturteil.
So English narrowed the word to a physical test, then widened the test to cover any hard experience.