Religion isn’t based on “the greater good”, it’s always explicitly about the will of the god or gods involved and obeying or appeasing them.
I agree that religions commonly use the god/god's will as the reason, but I don't think we should take that at face value. It's the argument to trump all others - rulers often claim to be chosen by the will of the supernatural - but not the reason the rule was made, which is a product of the cultures involved.
And humans often come to the same ethical conclusions: The rules against murder and rape, the priority on justice and fairness, as examples, are universal across cultures regardless of religion (look up 'cultural univerals').