"If everyone is replaced by robots, who exactly is going to be buying the goods and services these machines produce?"
That's thee communist utopia where one doesn't need to work but works for the pleasure. Obviously, that's only possible where productivity of the whole society iss sufficiently high and resources are plentiful.
Well that's right. The Earth is chock full of resources. The Sun is far from burning out. Why do human beings get hired by companies? Why do they get paid to do things at all?
It's because there are still no machines that can do what a person can do in many sorts of jobs. But that is quickly changing. As I've said, give it enough time, and there will be androids with human level AI and possible even more powerful. Then, why would a company hire a person to do a job, when the android can do it better, faster, and won't call in sick or pregnant.
It will happen. It will. And when that happens, society is going to have to face a very big dilemma. Either outlaw robots so people can have a purpose, or let the robots provide all goods and services and learn to enjoy leisure, living under the Providers.