Why did George Orwell write Animal Farm?
Orwell had been shaped by his experience in the Spanish Civil War and by watching the way the revolution evolved in Russia and then the Soviet Union. He was concerned, as so many in the West were, about the rise of Stalin and what he saw as a "cult of personality" being raised around him. This danger only appeared to increase as Stalin consolidated his power during the second world war.
Orwell himself described Animal Farm as his first effort to use an artistic novel to also try and accomplish a political aim. He was proud of the way he was able to combine the two elements into this very memorable and significant story.
In particular, he felt it was a better representation of Stalin and the Soviet Union than what was generally accepted in Britain at the time he wrote it. He wanted to push back against the very positive image of Stalin held by some leaders and bureaucrats in the government.
Orwell felt that political action and political speech were necessary in order to live a life of integrity and honor. Setting aside his particular views, we can say that Orwell wrote Animal Farm because he felt that he must say something about the political climate in which he was living.
Had he held different political views, he may have written an allegory informed by capitalist beliefs...who knows, but given his outlook on integrity he probably would have written something even if he wasn't an adherent of democratic socialism.
This is a great question. There is also a good answer for this. Here is some of the background that might be helpful. The book was published in August 1945. This is still the context of World War II. Also there was a rising feeling among the British and Americans that Stalin was a force that they needed to oppose. Orwell did not like what he was seeing. Although he was democratic socialist, he was very wary of Stalin. He did not agree with his type of communism with all the abuses of power - the arrests, which seemed arbitrary, censorship, and simple abuse of power.
In light of this background, Animal Farm can be seen as an allegory to his historical context. In short, the power of corrupt leaders destroys the possibility of any type of utopia.