In addition, getting into medical school is pretty difficult, so they have to be among the best students in undergrad.
Now let’s compare an somewhat analogous software engineer. Someone who has gotten a bachelors degree from a good college graduating near the top of the class. They now have 7 years of experience in their job. A possible equivalent of the competition for getting into medical school might be landing a job with FAANG.
Looking at levels.fyi, it seems that such a person would be making from 250-350K, which is comparable if not greater than an internal medicine or family practice doctor with a lot less stress and much fewer work hours.