"Now it came to pass in those days, when Moses was grown, he went out to his brethren and looked at their burdens. And he saw an Egyptian beating a Hebrew, one of his brethren. So he looked this way and that way, and when he saw no one, he killed the Egyptian and hid him in the sand. And when he went out the second day, behold, two Hebrew men were fighting, and he said to the one who did the wrong, 'Why are you striking your companion?' Then he said, 'Who made you a prince and a judge over us? Do you intend to kill me as you killed the Egyptian?' So Moses feared and said, 'Surely this thing is known!' When Pharaoh heard of this matter, he sought to kill Moses. But Moses fled from the face of Pharaoh and dwelt in the land of Midian" (Exo. 2:11-15).
We learn more about this time in Moses' life from Stephen's account in Acts 7:23ff. Although he grew up as an Egyptian, Moses' upbringing did not extinguish his feelings that he belonged to the people of Israel (cf. Heb. 11:24ff). Moses was 40 years old and had an understanding "that God would deliver [the Israelites] by his hand, but they did not understand" (Acts 7:25). How did he know this? Was it simply personal pride because of his unique position or had God communicated it to him in some way? Likely the latter, though if so he certainly rushed ahead of God impatiently. The killing of the abusive Egyptian was premeditated and unlawful on Moses' part, and the Israelites did not then see his potential as a deliverer. He overstepped his authority and failed to commit the act secretly, as he would soon learn when he tried to intervene between two Hebrew men who were fighting. His act of killing would eventually become common knowledge, even reaching Pharaoh's ears. The king tried to take Moses' life over the matter, but he fled to Midian and lived there the next 40 years. Moses' kindness helped him befriend the priest of Midian, Reuel (a.k.a., Jethro). Moses labored for him as a shepherd and married his daughter Zipporah, who would bear him two sons. Though Moses was safe from Pharaoh's wrath in Midian, he was not completely satisfied. This can be deduced from the name he gave his firstborn: Gershom, which means "I have been a stranger in a foreign land" (Exo. 2:22). To Moses, Midian was banishment and humiliation (at least at first). Moses' work as a shepherd for decades would help develop his patience, a virtue he would surely need in the wilderness for 40 years as a shepherd of the Israelite people.
"Now it happened in the process of time that the king of Egypt died. Then the children of Israel groaned because of the bondage, and they cried out; and their cry came up to God because of the bondage. So God heard their groaning, and God remembered His covenant with Abraham, with Isaac, and with Jacob. And God looked upon the children of Israel, and God acknowledged them" (2:23-25). While Moses was in Midian, the burden of the Israelites in Egypt continued, even under a new Pharaoh (whom perhaps they had vainly hoped would treat them more kindly). They were suffering greatly and they did the only thing they could: cry out to God for mercy! God was well aware of their situation and knew that the time was now right to deliver them (via Moses) and further advance the fulfillment of the promise to Abraham. Already they had become a great nation, and next they would receive a great land (Canaan). The sins of the Amorites had become full (cf. Gen. 15:16) and the enslaved Israelites were now properly motivated to leave Egypt. If they had been living in peace and prosperity, they would not have left Egypt. The same is often true today with sinners. They are not motivated to leave their sinful ways until they are greatly afflicted in some manner. Then their hearts may be more inclined to embrace a radical change, like becoming a disciple of Christ and shifting their focus heavenward (i.e., to our Promised Land).