I sort of agree with what you're saying but just wanna point out that you may not have gone to school and have have a loan etc.
But many many software engineers do. Many of us go to uni and study a traditional degree and therefore, have a lot of loans etc as well as spend 3 to 4 years in University.
Also, learning for a software engineer is pretty much forever since the moment you stop learning is your downfall in software development.
Becoming a doctor, for example, is a lot longer than 3-4 years and is going to involve a lot more debt. Also if you want to be a doctor you have no choice but to do all of that formal education and pay the huge sums. If you want to learn software development you can do so for free (excluding time but that is true of all learning). All you need is a computer and an internet connection. All of the software you need can be free, there are loads of excellent free resources and even the non-free things like books are not very expensive.
I know people many people who learnt to code in their own time for ~6 months and landed a decent first job. Over the next couple of years they learnt a lot more and now have great jobs earning within 20% of what a doctor usually earns however they don't have the debt and saved a few years of their lives as well.
Not saying everyone can do this and become a software developer but it is very possible. I don't have a degree, I had to leave school at 16 (I am now 32) and worked in a shop to get by. I self-taught and now I earn a few £ under £100k making software. I have a super comfy life. I have zero debt (well a mortgage but no other debt), a nice house, family, a fair amount in savings, etc. Honestly I couldn't ask for more especially considering the rather small investment I put into getting this lifestyle.
I went to school and graduated with large loans because my parents didn't pay for my schooling. And I agree with the parent poster 100%. Saying software developers are underpaid is on of the silliest and out of touch things I've ever heard.
But many many software engineers do. Many of us go to uni and study a traditional degree and therefore, have a lot of loans etc as well as spend 3 to 4 years in University.
Also, learning for a software engineer is pretty much forever since the moment you stop learning is your downfall in software development.