If you write a very successful book with traditional publishing cut you might make 30-40k. Average is lower. There are power laws at play, but as few as 5% make it past six figures.
So when I wrote a book about step-by-step user acquisition (https://secretsaucenow.com) I self-published. Made $60,000-ish in presales, sold another $60,000 while I was finishing the book. And now pull in 4-8k/month.
If I signed a deal with a publishing company selling the same number of books I would have made ~10k. Instead I found a freelance editor and typesetter ($400), printed the first 100 ($700), and sell the vast majority as eBooks. It's done well, but not earth shatteringly well, and I'm up above $140k in profit.
There is very little reason nowadays, IMO, to not self-publish.