There is a remarkable answer to this question by a responder in Quora. I find it quite logical except that the idealists of the communist movement overestimated the human factor. If human beings behaved as they morally ought to, perhaps communism would have worked.
I copy paste the response to make it easier for my readers to get the gist of the response.
Communism works—and has long worked—on the level of family. In a “normal” family, parents give to each other and to their kids according to their capacities and skills, often without expecting anything in return. Kids receive care according to their needs, often not giving anything in return. There’s an implicit promise that they will switch the roles when the parents get old and sick, and the kids become breadwinners. “From each according to his ability, to each according to his needs” is a Communist principle.
The system often malfunctions. Negligent parents and thankless kids are the stuff of a zillion tales, stories and soap operas. Amazingly, however, the arrangement reproduces itself generation after generation. It also inspires a powerful dream of extending the arrangement to the entire society. Every attempt to do it has down like a lead balloon—yet the dream resurfaced generation after generation.
Much of the Communist principle is also reproduced in faith-based communities (e.g., monasteries) and altruistic or idealistic organizations. Relief workers and their backers who distribute food and necessities in areas of distress help people out of charity. The recipients are not expected to give something back, apart from the implicit expectation that they in turn will lend a hand to others in need when the occasion arises.
The cartoon below is from a Soviet satirical magazine in the 1970s. The wife says to her husband: “You need to find a second job. Our kid has grown; he’s got a lot of advanced needs”. The reluctance of younger Soviet generations to sacrifice themselves in accordance with to the austere commandments of Communist ideology caused much chagrin to Soviet rulers during the sunset years of the USSR.”