I have been faced again and again with students who initially consider working in academia, but in the end chose to go to industry. I feel like I often fail to explain to them why I feel like academia, while not perfect, is a wonderful place to be. Here is one more attempt.
Disclaimer: I am a researcher in an extremely privileged environment and field, so some parts might sound over-optimistic/completely irrealist to researchers/professors who are suffering from degraded work conditions, which unfortunately is the case in many places. This is written for PhD students in a position similar to mine, i.e. AI PhD students in a top university at a time where the field is growing exponentially.
From 25 to 65 (or more) you will likely spend most of your awake time and energy on work: if you are lucky and have options, be sure to pick something that's not only enjoyable, but also deeply meaningful to you. A lot of companies talk about impact, but spend some time thinking about the impact you want to have.
Why are you paid in a company? One way or another, to increase the company value. That's not because the company is evil, it's just because it's a company, the very reason for its existence is to make money, and if management forgets it, shareholders will be sure to remind them.
Why are you paid in academia? To teach and to do research. Once you have a permanent position (which can take some time depending on countries, but is quite fast in France), you will have in many countries (and France in particular) a very specific status that is essentially there to make sure you are independant, can do research in the direction that you think is best, and teach what you think is best.
I know little about non-profit and the rest of the public sector, but for sure working there also seems to make much more sense to me than in the private sector.
Freedom in your work in a company sometimes has clear explicit limitations, but very often there are mainly plenty of softer incentives that prevent you from asking too much of it and constant nudges pushing you in the direction the current company policy wants you to go. Since you likely won't have infinite energy every day to push in your own direction, since it's hard to decide to 'underperform' and since it's tempting to be rewarded or achieve the goals set out for you, it's likely you won't go too far from what the company expects you to do.
Of course, you can always change companies if what's expected of you becomes too far from your values, but that will require quite a bit of effort, and might not be easy depending on the current state of the economy.
Also, if like me you have trouble with people telling you what to do, you won't really have a boss in academia.
PhD students are great for many reasons:
Research is very horizontal, as a permanent researcher you will have a clear impact on your research lab and still have the opportunity to build your own research group. You really have a very large freedom to build your work environment, take measures to make it nicer and more nurturing. This includes hiring, at least for PhD students and postdoc. You also set your own goals for you and your students, in particular in terms of research and research directions, and can try to convince other researchers to follow you. You define your work and the one of others.
I would likely get angry if I started to write about public policy for research and university, so I am definitely not saying the system is great. However, most hiring committees struggle to find good candidates:
Money is one of the key arguments of students who choose industry. I do understand that, especially after having been underpaid as PhD students, and in a state where researchers/professors salary is typically incredibly low compared to what they would have in the private sector and where public salaries decrease (because they don't follow inflation and even less private sector salaries, but I said I would not get angry). An easy solution would be to go abroad, researchers salary in Germany, Switzerland or in the US are still not competitive with the private sector but much more comfortable, but you might want to stay in France (I think it's a great decision). However, even in France, researchers/professors salaries are not so low that you cannot live with them, and they evolve in a predictable (and even immutable) way as you grow older (e.g. you can look for the 'grille indiciaire' e.g. for starting researchers and junior professors). Note that because taxes are different in public and private sector, comparison of the salary 'before taxes' (=brut) is meaningless and makes the difference with the private sector seem much larger than it actually is. If these salaries really are a problem for you (e.g. you live in Paris and want to have kids), there are other options to stay in academia. The "chaires de professor juniors" are a new status in France that was design to shortcut standard carriers (CR-DR, Maître de conférence-Professeur) and attract people with a clearly higher starting salary (at the cost of having a temporary contract, but universities can convert them in permanent positions, and since they need skills on the positions they offer, they likely will). There are also diverse research institutions with their own specific status, who are able to offer different salaries (e.g. CEA, ONERA) or even negotiate them themselves (e.g. some engineering schools). And there are various ways to get paid more depending on the exact position and status, including different bonuses, paid teaching and you can even do some consulting. I realize this is a huge mess, but unfortunately I don't know a better way than talking to various people to know more or less what you can expect for each specific position.