This sounds like a fairly idealized vision of what working in medicine is like. I have heard doctors say the same sort of thing about being a software developer. Is the grass really greener?
We all have different things that we're looking for in life. For instance, most of the things that I commonly hear people complain about in software development have never once bothered me (bureaucracy/incompetent managers, deadlines, long hours, etc.).
A doctor who isn't interested in any of the benefits of the career that I listed may indeed end up resenting their choice to take on a lot of debt (and study for at least seven additional years) just to end up in a big city alongside programmers with no debt making a similar amount of money.
Like I wrote, if you're motivated by money, medicine is a fairly bad choice. How many doctors are neurosurgeons? About half a percent. Of those, how many are department chairs? Just a handful.
If you want few working hours, medicine is probably a bad choice. How many doctors are radiologists who co-own a business and take half the year off? I don't have a percentage for this one, but very few. Most will work 50-60 hours a week.
How many programmers know that their startup is still going to be around in 40 years? Very few. How many programmers have the option of working where they want without taking a pay cut or working as a contractor? Very few.
The grass certainly isn't always greener. If it were, then I might have picked law, or architecture, or construction, or any of a vast number of other options. But none of those fits the list of criteria that I now know are important to me in life (but may not be important to you).