My take is that Dave Ramsey's advice has more to do with human behavior than math.
Like when he tells people to pay off the smallest debt first, even if it's not the highest interest rate. Obviously, with all things being equal, one should pay off the highest interest debt, but all things are not equal. There are many people who become discouraged when they try to pay off the higher interest debt and fail. Paying off the smaller debt is easier and succeeding leads to a real psychological boost and helps many people keep with the program.
Likewise, owning a house is very different from owning a stock portfolio. Investments are pretty easy to cash out of while selling a house is a bigger deal. A house often turns out to be the largest asset some people have and can be cashed out when it's time to move into assisted living. I know both my DMIL and my DGM sold their houses when it was time to move into assisted living and the cash from that provided the money they needed.
Now, I know all of us here in this forum are strictly rational and will do whatever it takes to earn an extra 1% on their money
but owning a house gives many people a real asset they can rely on.