Also keep in mind it's much more egalitarian. In law yes you can eventually make partner at a white shoe firm and make millions (and make FAANG money at a Xth-year associate) but the competition is staggeringly intense.
Let's say I'm 18, intelligent and ambitious, I live in the USA, and I want the quickest path to making $500k per year and my choices are law, medicine, and computer science.
I sincerely hope that for everyone on HN, the answer is a no-brainer.
The doctor making 200k stitching up chainsaw mishaps in some small city can live on several acres (or in the nicest suburb of that city if that's his preference), send his kids to private school, he drinks $2 milk and fills his car up with $2 gas. Try living like that in SF or any other "tech hub" on 200k.
I'm not saying tech isn't easier and doesn't start off making big bucks faster but doctor probably takes the lead around age 30 or so. If you wanna make big bucks without going into management doctor seems like the better route.
Also, doctors have to deal with the byzantine paperwork nonsense in the health field, and work with the general public as well as in places that have infectious diseases floating around. And can't work from home as easily. I wouldn't trade not having to work with the general public for a couple hundred thousand.
I was a somewhat successful premed student (99.9th percentile MCAT, CS major), and I went the FAANG route instead. Physician and tech salaries are similar in that the top makes alot more than everyone else, although the bottom for physicians is a bit higher. For less competitive people who may only have only gotten into a single med school and whose job prospects with a biology degree are limited, the med route can make sense from a purely financial point of view.
Becoming a doctor is significantly more work than becoming a programmer.
Plus, I work a set schedule, with easy, predictable hours. Doctors get to deal with on-calls and 12 hour shifts.
Now I'm a software developer. Primary reason for the switch? It's so much easier for the same amount of pay.
I work the same hours, I get paid the same amount. The questions presented to me in both jobs were fascinating and the work was satisfying.
When I got home from being a lawyer I was dead to the world. Exhausted from a hard day's work.
When I get home from being a software developer I've still got enough vim and vinegar to take my son to the children's museum or the library. Every day.
Anecdotal yadda yadda yadda. But I assume the pool of people who have been both lawyers and programmers is, if not tiny, then small.
The attrition rate for "pre-med" freshman actually becoming a doctor is much higher than CompSci/Eng students becoming SWE.