You aren't looking far enough into the future. In the short to medium term, despite machines doing the work of many men, having more technology will likely create more jobs and industries that were previously non-existent. However, after the singularity (https://en.wikipedia.org/wiki/Technological_singularity), not only will the jobs humans had be taken, but the new jobs created will then be taken by more qualified artificial intelligence which can watch over itself at a fraction of the cost of human work.
The upshot is exactly what you said: society is getting richer, and despite less jobs available in the distant future, everything will be virtually free and we will have limitless resources when AI and machines can harvest the Solar System. As a previous commenter also said, we will have much more free time to enjoy our lives and do as we please (assuming AI doesn't enslave us a la I Robot, Terminator, etc).
Thanks for your comment, @daut44. I read all the books of Ray Kurzweil and others and would consider myself as of a kind of a transhumanist. But I don't have any clue, what will be the outcome of the Singularity. There are different likely scenarios. And everyone of it has some evidence.
So let's assume, that there will be robots with artificial intelligence that could replace humans at any task and will be better than the human with it. Think of Data from Star Trek. But what about the people-to-people interaction? Is an artificial person in the same way interesting for a human being than another human? There will be areas, where humans still wants to be served by humans. - Ok, maybe there are not enough of this jobs for all the humans or not any one has the requirements for them. The other humans could then maybe paid by machines for acting their life. Think of is as the computer game "The Sims" with real people. As a scientific project or entertainment for the machines.
Hugo de Garis is not so optimistic. He said, that the machine gods could kill us, like we kill a fly, that annoys us. A rather optimistic outlook came from Stanislav Lem. He said, when we are lucky, then the machines keep us as pets. And Ray Kurzweil hopes that we will upgrade ourself, so that we will become equal capable like the artificial intelligence. Thinking about the Singularity is awesome. But nothing is for sure.