Well, you are both right. Compensation is set by the market, but the ceiling for compensation to perform a task is (roughly) the amount of value that a employee can generate, in a rational market.
Of course, our market is far from rational, etc, etc.
FWIW, I don't think that software developers are overpaid, at all. It's a difficult career, requiring years of intense study to do well. Sure, maybe not as much as Doctors, at least not formally, but a lot of that has to do with the structure of medical education in the United States (in particular, the requirement to complete an undergrad degree prior to admission to medical school). The job of a surgeon is certainly more difficult than the average software developer, but compared to a SRE at Google, say, who is working with real, "living" distributed systems that interact in complex ways, I would say they are comparable. If anything, I'd expect, in a rational market, for the SRE to be paid more, because their services are providing for millions or billions of customers, while the surgeon is only providing for one at a time (and maybe a few thousand over their carrer).
What I usually reach when thinking along similar paths, using me (programmer) vs my doctor friends, is the failure scenario:
If I introduce a bug it will hurt revenue in some way, possibly affecting the company's operations. If most doctors mishandle a patient it could have significant, immediate effect on that person's life.
I deal with the responsibility weighing on me, but they've had to get used to dealing with a much heavier responsibility.
Of course, our market is far from rational, etc, etc.
FWIW, I don't think that software developers are overpaid, at all. It's a difficult career, requiring years of intense study to do well. Sure, maybe not as much as Doctors, at least not formally, but a lot of that has to do with the structure of medical education in the United States (in particular, the requirement to complete an undergrad degree prior to admission to medical school). The job of a surgeon is certainly more difficult than the average software developer, but compared to a SRE at Google, say, who is working with real, "living" distributed systems that interact in complex ways, I would say they are comparable. If anything, I'd expect, in a rational market, for the SRE to be paid more, because their services are providing for millions or billions of customers, while the surgeon is only providing for one at a time (and maybe a few thousand over their carrer).