In an anarchist society, or a society of "higher" or full communism, who does the necessary and necessarily unpleasant work required to keep society functioning?
Firstly, much work perceived as necessary is a result of social choice. Shit shovelling, as a quintessential example has been widely replaced by sewering or compost-toileting or mechanised sewage removal. Many "necessary" roles may in fact not be.
Secondly, work isn't "necessarily" unpleasant. In the Australian context, sanimen who carried the can in relation to sewage disposal were decently paid and well respected. Garbage men used to be sinecures given to local amateur sports heros. Sewering engineers were well paid, particularly after society recognised their responsibilities. Society and culture produces the unpleasantness of some work, by declaring it to be unpleasant.
The core of the question is why would people do necessary work, the largest direct answer is someone will want to do anything if you ask them to do it. The second section of the answer is some people will do anything if you ask them to do anything. These arguments rely on the idea of the excess of productivity in existing society being largely spent on waste, which would therefore reduce the real necessity that people would not otherwise choose to do to a minimum.
- The idea of necessary work is largely wrong
- The idea of necessarily unpleasant work is wrong
- People will voluntarily choose to do needed things, particularly if they're asked to do so and respected for doing so
Only speculative answers can be given, based on various visions of communism or anarchism, since the actual 'pure' communism/anarchism was not implemented.
The modern examples of communism, like kibbutz or open source, are based on volunteers. Volunteers are a special group of people, and they are free to leave in any moment. We have no idea how would, for example, kibbutz function if there were people born there with no option to leave. The Machno state was a rural one, short lasting, and was never self-sustaining (in that sense it didn't produced all the tools it used) and it was de facto a form of military government.
The technological vision of communism (like Star Trek) is very near (if not exactly) what the Marx described as building the material basis for communism - the production is automatized to the amount, where there is enough goods to fulfill people's needs. In that world, any dirty or boring work is made by machines, the people do only the creative work.
Communism as such does not exclude government, and the justice concept requires to give anyone everything they need, but to demand to give back to community as they are able to, so people who are not able to do more sophisticated work, may be forced to do the unpleasant/boring one.
Anarchism as such bans institutional government, but the human remains the social being, therefore prone to social pressure. If you expect anyone to work for society, the social pressure for the people that do nothing should be enough to move at least some of them to do the unpleasant job, so they won't be looked down as parasites.
Anarcho-capitalism removes military pressure from government, but leaves the pressure that can be just as effective - the economic pressure. The people will be forced to do any job, no matter how unpleasant, in order to survive.
Who shovels shit around here?
Just to use what I think is a pretty apt comparison, the SE network is pretty communal if not anarchistic. Community rules are more or less agreed upon by the community and mostly enforced by the community.
But who handles the less desirable work around here? Who deals with the worst of our rubbish?
Why do people decide to take on moderator positions? Often it's because they're held up with a certain regard, and they like their community enough to want to be of service.
Here's to you, the glorious janitors.
Society will allocate more resources to get rid of nasty jobs. If everyone doesn't want to do it, then they'll be willing to spend more time working at other things (generating wealth) to trade for someone willing to shovel the shit.
If everyone is given everything they need, and nobody needs to work:
Self responsibility: You have to shovel your own shit, since nobody else is willing to do it for you.
Draw lots: Bad luck dude, you're shoveling shit today.
In order: It's your turn to shovel shit today.
Some people won't mind shoveling shit, or will be more efficient at it. And they will collect money (if it exists) or favors on the black market and shovel other people's shit, in order to get more/have more/get laid more/whatever.
And imagine a real labor market. What if every job was up for bid, and didn't rely on old-boy networks, seniority, etc? With real job requirements (not, say: needs an Ivy league education (which is just a white-washing the old-boy networking requirements/have enough money to buy your way in)).
How much would you bid to: play golf with other decision makers, have a private jet, secretary, change company policies, determine products or services offered, business direction, etc?
Or, fly into space and perform experiments?
How much would you bid for a needed salary to wear protective gear, get medical checkups, and shovel shit?
I suspect you'd bid at least 100K to be the shit-shoveler, and maybe bid -10K (or whatever you've got in savings divided by 10) to be the CEO.
If the job was determined by selection amongst the lowest bids, the highest paid jobs would be the worst jobs, and the best jobs would cost money to have, or pay next to nothing (you'd work a bad job for years in order to buy your way into a nice job). This would result in bad jobs being automated away, and good jobs being broken apart so there were more of them.