This paper examines how the interplay between economic incentives and social preferences transmitted by ideology plays a role in the rise and fall of communism. We introduce inequality-averse and inefficiency-averse agents and model their conflict in ideology, triggered by envy. The socioeconomic dynamics generate a pendulum-like switch from markets to a centrally planned economy abolishing private ownership, and back to restoring market incentives. The grand experiment of communism is thus characterized as leading to the discovery of a trade-off between equality and efficiency. The model also derives conditions under which the two systems converge and become stable.