An earlier version of this essay was my submission to the St Gallen's Essay Competition.
This question is relevant because there are good reasons to believe that AI will eventually surpass humans in every task which is based on analysing and processing information and knowledge. By “information”, I do not mean just numerical data, but rather every form of communication: speech, text, diagrams, videos, etc. These tasks make up almost all white-collar work and much blue-collar work as well; their future should therefore be an issue of great concern.
The inevitable dominance of AI in information-processing tasks
The first is that, mathematically speaking, an “information-processing task" is merely a function from input variables to output variables. In many cases, it is true, these input variables are very complicated: doing a typical task might require background knowledge about society, an understanding of human psychology, and years of experience in that role. It is practically difficult to encode such things into computers, but in principle there is no insurmountable barrier.  We simply need better ways to search for algorithms which implement such functions.
The second reason is that such a search cannot be too difficult, because blind evolution has created our own intelligence. Relatively complex tool use has in fact evolved at least three times in significantly divergent taxa - corvids, primates and octopuses - which suggests that this step is not a major bottleneck.  The further development of human intelligence from the level of chimpanzees took less than two million years and 200 000 generations: a minuscule fraction of the four billion years since the origins of life on Earth.  The fact that these two million years were spent selecting not just for intelligence, but also many other physical and mental characteristics, suggests that a more finely-targeted search procedure could converge on intelligence much more quickly.
If we had to search from scratch for every different task, then perhaps automating everything would be infeasible. However, our evidence so far implies that intelligence generalises easily. During the evolution of modern humans, there was no selection pressure for the abilities to design complicated machinery, solve abstract mathematical problems, or organise logistics for millions of people. The fact that we are now able to do all these things at a very high level, despite being "designed" by nature for an entirely different environment, tells us that there are core intellectual competencies which confer advantages in many domains.
The fourth reason is the massive advantage that silicon-based computational hardware has over the equivalent biological hardware, i.e. brains. It's true that our best estimates judge the processing power of a brain as similar to that of top supercomputers.  However, humans aren’t very efficient in converting this processing power to calculation. We need to use some to control our bodies; some to focus on our emotions and relationships; and we need to spend a large portion of our time sleeping and relaxing. We also trail behind in communication ability: computers can transfer gigabytes of data in the time it takes to say one sentence. This means that groups of people working together need to spend a lot of time pooling their information, and that when a human retires, they can convey barely a fraction of their knowledge and experience to their successor. And given expected advances in computing hardware, today's supercomputers will be tomorrow's personal computers. So even an AI whose reasoning capabilities are "only" at human level could still massively outperform humans in every information-processing task.
The continued economic relevance of humans
I have argued that, inevitably, AI will utterly outclass humans in performance on any given information-processing task. This does not mean that humans will necessarily be shut out from those industries: by Ricardian comparative advantage, it could still be profitable to employ humans even when they have no absolute advantage over AI.  However, since copying software is trivially easy, and the price of hardware continues to plummet, such roles will be very limited, especially if there is any sector of the economy in which humans have a comparative advantage over AI.
I claim that there is such a sector, consisting of what I shall call 'social jobs’. I define these as jobs where most or all of the value produced comes not from their outputs, but from the fact that they are being performed by other humans. The principle is most clearly illustrated by personal relationships: we want friends and partners who not only say and do the right things, but also really feel love and respect for us. In the economic sphere, there are particularly important social components of jobs in sales, management and leadership, and entertainment. To understand them, it's instructive to consider jobs whose value is almost entirely tied to the fact that humans are involved. Take chess, for instance. If we view the value of professional chess players as due to their production of high-quality games, then the advent of superhuman chess engines has rendered them entirely redundant. Yet professional chess not only still exists, but also features ever-growing prize pools.  So we are better to model chess players as entertainers, whose humanity is central to the existence of their jobs.
There are plenty more examples to consider. Fans of sports matches or rock concerts could often see and hear the performances better if they watched a broadcast from home; however, as with most entertainment, it's the atmosphere and sense of connection with the people around them that they value more. A robot could say and do all the same things as a lobbyist or politician, but couldn't build the personal relationships that are crucial for both jobs. An AI counselor might be much more knowledgeable about psychology than a human one, and yet be much less able to convince the patient that someone actually cares about them. In all these cases, the outputs produced by an AI may be very similar to or better than a human's, but we would assign the latter much more value, because we care that there is a person on the other end of each interaction. In fact, humans will be able to do such jobs much better by incorporating analysis from AIs into their judgements - but human participation will still be essential.
Growth in these roles, and the social economy overall, will be driven by massive increases in overall wealth. Piketty estimated that world GDP increased by a factor of 140 between 1700 and 2012.  Historically, such gains have led to significantly increased spending on entertainment, and the rapid expansion of intrinsically social sectors like fashion and tourism.  Such spending is the most likely to support irreplaceable human jobs in the long term, for the reasons I outlined above - and there are good reasons to think that the current "Fourth Industrial Revolution" will be of even greater scale than its predecessors, allowing these social industries to grow rapidly. 
It may seem that, even so, there will simply not be enough social jobs for everyone. However, it’s unlikely that the current dichotomy between employment and unemployment will last indefinitely: technology is very good at introducing flexibility to previously rigid systems. Amazon's Mechanical Turk, for instance, is a marketplace where people can be paid for doing various tasks whenever they want, without any commitment or fixed hours. Driving for Uber or Lyft is the same. There are also now many games where you can trade virtual goods gained during gameplay for real money. These particular opportunities will eventually be automated away, but there will be plenty of replacements - and if global wealth increases to the extent suggested above, then such part-time jobs will be sufficient to maintain a reasonable quality of life.
In fact, we are already seeing surges in flexible social jobs, driven by the ease of connecting with people online. "Social media influencers" such as Instagram stars can earn millions; so can motivational speakers and life coaches with popular Youtube videos.  The massive earning power of media figures and celebrities is not a new phenomenon, but it's important to note the decreasing barriers to entry. Anyone can set up an Instagram account and start amassing followers (even if right now only a few can monetise effectively). Meanwhile, websites like Patreon, Kickstarter and meetup.com allow grassroots entrepreneurs and content creators to reach larger audiences (and profits) while remaining responsive to their supporters.
The ability of technology to facilitate peer-to-peer interactions suggests the potential for social jobs to become far more bottom-up (as opposed to the top-down model epitomised by TV culture). For example, during the last century an incredibly broad array of subcultures - from board game enthusiasts to queer communities to the worldwide competitive debating circuit - have largely been run by unpaid volunteers. However, if more wealth will indeed be funnelled into entertainment and leisure as the AI revolution progresses, and tools for distributing this money continue to be developed, then the economies of these communities will become more complex, with more opportunities to translate passion for a subculture into a decent wage. This is exactly what happened in many sports over the last century as participation and viewership boomed. Now millions of people are employed in sports-related jobs - and many such roles will never be automated away while the sport lasts, because their social aspects are pivotal in tying their respective communities together, and because they confer prestige within each community.
The exact activities and achievements considered prestigious will, of course, be mediated by cultural factors. For example, domestic workers make up less than 1% of the workforce in developed countries but up to a dozen times that in other parts of the world.  A significant portion of this disparity can be attributed to cultural reticence towards hiring "servants" in the West. However, in general, consuming goods or services is more prestigious the more scarce or expensive they are. For example, in very poor countries possession of factory-made "Western" products can be a proud distinction. Yet in countries where automated production of goods is commonplace, it is the opposite: markets such as Etsy are able to charge a premium for handmade goods. In a future where goods and services can be produced incredibly cheaply by automation, the ability to hire other people to work for you will remain a scarce resource, and therefore will in general become more of a signal of social status. Fast food outlets, which compete mostly on price, lead the restaurant industry in automation; whereas the fanciest restaurants and hotels, which compete mostly on reputation, will likely always keep their human waiters, chefs, valets, receptionists and concierges.
The predictions I have outlined above depend on people still caring about the distinction between humans and robots. I think this is likely. Friendships and relationships are fundamentally based on a mutual emotional bonds and shared concsious experiences between equals. Of course, consciousness is mysterious, and perhaps we will create AIs who (we are convinced) consciously feel emotions in the same way as humans. However, unless those AIs are specifically engineered to be very similar to humans, there will be certain facets of human relationships that they can't replicate. Could you feel like an equal in a friendship with a being who thinks ten thousand times faster than you, living a lifetime during each of your days? Or wholly trust a partner intelligent enough to manipulate you in any way they desired? I don't want to say that such shifts will never occur, but my best guess is that even in the very long term, most people will want their personal relationships to continue involving other humans. And as long as these non-transactional experiences are highly prized, then it will be economically valuable for human workers to evoke emotions that AIs do not. Even if distinguishing AIs from humans becomes difficult in some cases (e.g. via convincing facial and vocal simulations), it also seems likely that legal measures will be taken to prevent AIs from masquerading as human.
- Stuart Armstrong, Kaj Sotala and Sean OhEigeartaigh. 2014. “The errors, insights and lessons of famous AI predictions – and what they mean for the future”.
- Jack Copeland. 1997. “The Church-Turing Thesis”. Stanford Encyclopedia of Philosophy.
- Carl Shulman and Nick Bostrom. 2012. “How Hard is Artificial Intelligence? Evolutionary Arguments and Selection Effects”. Journal of Consciousness Studies.
- Matthew Dodd, Dominic Papineau, Tor Grenne, John Slack, Martin Rittner, Franco Pirajno, Jonathan O'Neil, and Crispin Little. 2017. “Evidence for early life in Earth’s oldest hydrothermal vent precipitates”. Nature.
- Larry Greenemeier. 2009. “Computers have a lot to learn from the brain, engineers say”. Scientific American.
- Free Exchange blog. 2009. “Rethinking the Luddites”. The Economist.
- Matthew DeBord. 2015. “The world’s top chess players have just formed a new $1 million professional tour”. Business Insider.
- Thomas Piketty. 2014. “Capital in the 21st Century". Harvard University Press.
- U.S. Department of Labour. 2006. “100 Years of Consumer Spending”.
- Klaus Schwab. 2016. “The Fourth Industrial Revolution: what it means, how to respond”. World Economic Forum.
- Tom Bartlett. 2018. “What’s so dangerous about Jordan Peterson?”. The Chronicle of Higher Education.
- International Labour Office. 2013. “Domestic Workers Across the World: Global and regional statistics and the extent of legal protection”.