Religion conforms to the ideas of the ruling class, not the other way around. Historically, religious aristocracy may become a class of its own with enough political power to challenge a ruling class, but they often have little reason to do so when they're already part of the club, so to speak, and even when that happens, the religion conforms to the ideas of the new ruling class. The evolution of Christian canon and its various schisms throughout history immediately jump out as an example to me cause I was raised a good christian boy.
This goes both ways, however. There's no shortage of examples of class struggle under a religious banner. From Protestant Europe, to Colonial Haiti to Qing-Era China.