I would suggest that moral codes come from a baser form of instinct. Packs of dogs, herds of sheep, flocks of birds all exhibit a form of "moral code." They do whats good for the group. Well humans have this same instinct. As survival to propagate is the sole reason we truley exist we need to have means to survive.
Think about it, small groups of humans lived and worked together to surive, waring with rivals. As we became more "civilized" and our small groups enlarged until what we have today(a global clan) we have developed rules and laws to govern our actions. These moral codes are what enable us to continue to dominate the planet. Religion really has nothing to do with it. Religion is the natural progression from myth. Myths were stories to answer questions we had no answers to(The gods live in the sun, wind is Zues sneezing, whatever) As more people ascribed to these myths religions we born from them. Judiusm is no different, growing from the myths of Yahweh.
Groups that shared the same religous beliefs incorporated pre-existing moral codes into their dogman(ie 10 Commandments and the like) because those codes ensured(or were thought to ensure) the life of the religion. But the codes were already there, inborn.