The story of Moses and the pilgrimage from Egypt is a familiar one. God has brought his people out of bondage. He says as much in Exodus 20:2. In fact, this is the very introduction to the Ten Commandments. "I am the Lord thy God, which has brought thee out of the land of Egypt, out of the house of bondage."
God has redeemed his people and now they are returning to the promised land. God must have looked at them and realized that some changes needed to take place. The first thing that he asked for was some respect. The first four statements he makes have to do with Him: no other gods before Him, no graven images, no bowing down to them, and don't take the His name in vain.
The last six have to do with how other people are to be treated: honor your parents, don't kill or commit adultery, don't steal or bear false witness, and don't covet your neighbor's possessions. Those are the ten commandments.
Four hundred years they spent in bondage. Four hundred years among pagan worshipers. Four hundred years of mistreatment. Is it any wonder that God wanted his people to write these commandments on their hearts so that they could have a better life than the one they had been in.