I wish I could just "chose to be a professor". But you are correct in your assessment that, for people who chose to stay in academia, money could not be the motivation.
But, doing a PhD is not just obtaining another diploma, just another step in one's education. The knowledge (i.e. collection of facts related to your field of study) obtained during a PhD is so specific that it is not easily transferable. The transferable skills a PhD candidate trains for have to do with understanding scientific literature, being able to make connections, conclusions and get new ideas from it. After obtaining their PhD, one should be able to do that reasonably well with literature from any (sub)field related to theirs, after a short period of time needed to come up-to-speed with a new topic.
On the other hand, skills required for a software engineer are a different set of skills entirely. A masters education will sometimes familiarize you with the basic tools (programming languages) and concepts needed, but you eventually need to develop skills related to writing legible, repeatable, reusable code, which you mostly obtain by a lot of practice. Judging by some of the industry interviews I had after my PhD (in parallel with the postdoc interviews), I would've probably done much better in them before my PhD, or even before finishing my masters.
So, they're jobs requiring different skillsets. I chose Computer Science because it fulfilled me, unlike e.g. medicine or law. Taking this further, I want a research job because it gives me a sense of fulfilment I wouldn't get from a software engineering position. Pure research positions in top-tier companies are quite competitive, so there's a slim chance somebody who can't succeed obtaining a permanent faculty positions will be able to secure a research position in industry.
Some of the following points are what is important to me, rather what might be important to everybody, but I heard most of them echoed back to me from my colleagues in academia. Comparing research positions in industry and academia (though my experience in industry is limited to what I got from a few interviews, and then a few months where I was forced to take an industry job while waiting for my immigration documents):
Most research positions are much more flexible with working hours. People understand that, doing creative work, some days you just can't get anywhere, and some days you're on a streak and don't want to stop after 10 hours. People that are really not morning people can occasionally arrive late for lunch, and nobody says a word.
In industry, I've heard arriving to work at 9:30AM is considered as having "flexible work hours".
Even in case of very strong research ties to industry, holding an academic position allows you to chose the problems you want to work on (possibly amongst several industry collaborations, but the choice is still made according to your research interests and research group).
In industry, you need to work on the problems as dictated by the market, interesting be damned in favour of profitable.
In my academic interviews, people were interested in the problems I was tackling.
In industry, people were interested in my problem solving skills. Nobody cared about what I applied them to, just whether I can apply it to the problems they would present me with.
Academic jobs are some of the most travelled jobs out there. During my PhD, I wouldn't be surprised if the amount the University covered for my travels would have easily closed the wage gap to industry. Conferences and professional visits are an integral part of academic research.
Travelling with industry always has a promotional purpose.
I feel free to discuss my ideas with anybody, anywhere. I reach best conclusions through discussion. The thought of chatting about a topic, having an idea and having to bite my tongue is a bit terrifying to me. The worst that could happen is somebody poaching an undeveloped an untested idea and researching it themselves - not a terrible loss since I don't get to develop all of my ideas anyway.
In industry, one needs to constantly think of confidentiality, and which details of their work they are allowed to disclose.
The goal of publications, as the "tangible products" of academic research, is to share your ideas, results and findings with the world. I enjoy the idea that my work is public and adding to the collective of human knowledge (let's not discuss paywalls right now...).
In industry, all the ideas have to be intellectually protected before publishing: patented or whatever. The goal of publishing is not, precisely, to share your approach with the public. It is again promotional; to boast about the results you obtained with your new method; the details of which you might (need to) try and keep vague.
In my head, the list of contrasts goes on. It's little things and big things, but all in all, all the freedoms that staying in academic research allows me are worth more than the difference in monetary compensation industry could offer. If somebody wanted me to work a 9-5 job (or generously allowed me to work 9:30 till 5:30), working on their problems which I find marginally interesting, and not discuss my work with anybody not on their payroll (and sometimes not even that if employees are too competitive for promotions), they would have to offer me much more than the industry standards. Since I'm not a research rock star and nobody is going to offer me that, I guess I'll stay in adacemia if I can, and leave an industry engineering job as a fall-back option.