This is one of the biggest questions as the singularity compresses the deployment of capital and material resource allocation: if the majority of people aren't competitive with machines, who provides for them and how is that structured?
New technology doesn't eradicate what came before. It only replaces what's profitable. There are still some people in the world subsistence farming. A tech worker is many orders of magnitude more productive in monetary terms, but hasn't replaced them. In the worst case, automation (including physical) may drive the cost of labor far down, but it cannot drive it to zero, and as it does so commodity goods will become cheaper as well. (Housing, education, and healthcare prices are inflated for policy reasons. Expect to see increase in unregulated alternatives for housing and especially healthcare.)
Net effect: huge inequality, many people buying very cheap goods for tiny wages. Middle class destroyed. Lots of struggle. But not as bad as some folks are saying. History zombies on.
History provides the same answer every time this question arises
You will starve to death while Musk gets a luxury space yacht.
There's a darkly simple answer - they won't be provided for, they'll be culled.
If we are outdone in intelligence, diligence, and creativity, humanity will have to fall back on its weakest talents - integrity, fairness, and compassion. What a nightmare.