Humans are a social animal. Living together is a survival mode. Living together requires a moral sense. It's written in our genetic code.
Lizards are not social animals. Living together reduces the food supply of each one. It makes no sense for lizards to live together. It is written in their genetic code.
So, we look into ourselves to find the truths of being a human. Two things spring from this truth-seeking effort that has lasted for thousands of years - morality and religions.
So, one is not the basis of the other. They both come from looking at who we, as a species, actually are.