If buying a house isn’t the answer, what is? Renting forever?

I keep seeing people say that owning a home is this unnecessary “American dream”, and that it’s a bad idea, since most people don’t want to stay living in the same spot for the rest of their life.

My question would then be, “If buying a house is not smart, what is the smart decision?”. Is it just renting a house/apartment for the rest of your life? I did some math based on national averages in the U.S., and it looks like buying a home is a bigger investment of cash up front, but renting for your entire life would cost more in the long run. So what exactly is the answer here? I’m becoming more and more worried about how i’ll ever be able to find affordable housing.