Karl Marx may have said that religion was the opiate of the masses, but he also said that it was the "sigh of the oppressed creature, the heart of a heartless world, and the soul of soulless condition." In other words, it just might be the only thing that gets you out of bed in the morning—if you're an oppressed laborer, that is. So, what does Animal Farm do with this? Moses might be a manipulative liar, but his little tale about "Sugarcandy Mountain" is also the only thing that keeps the animals going after a long day of hauling hay. We don't blame them for wanting to believe it—but we can blame the pigs for using it against them.
Orwell is suggesting that the only reason religion exists is to make people feel better about their horrible conditions.
Although they play very different roles, Moses and Napoleon derive power from and interact with the other animals in similar ways, making clear a connection between dictatorship and religion.