At the beginning of the 19th century, doctors were few in number and there were many other people providing medical help, especially to ordinary people with few qualifications. Only in the course of the century did a clearly identified medical profession emerge with recognised standards of conduct. See "Who is a doctor?".
As a member of a profession, originally the doctor received an honorarium (a voluntary expression of gratitude), rather than a fee. All the same, in the nineteenth century, doctors were able to sue the patient (or his heirs) for that honorarium in contract. But the patient could only sue if things went badly wrong. Lawyers did not focus on what the doctor promised in return for his honorarium. Instead, they set the same standard of care whether the doctor was paid or not. See "The Skill of the doctor".
How many lawyers does it take to make sure a doctor gets the money hes technically not entitled to?