The meaning of Moses’ stay in Midian is threefold:
Moses marries one of Jethro’s daughters, Zipporah, and receives two sons, Gershom and Eliezer (Exodus 18:3–4).
Moses lives as a foreigner in Midian; he is an outlaw on the run for the Pharaoh. He also calls his son Gershom (= a stranger there). A foreigner lives in a vulnerable position, just like Abraham, Isaac, and Jacob lived as aliens and strangers (Hebrews 11:13). As a stranger he has to learn to trust the Lord. And he did; we see this in the name of his second son, Eliezer, meaning the Lord helps (Exodus 18:4). In faith he expects the future (the heritage) from God (see Hebrews 11:13). God disciplines him (Hebrews 12:7).
God prepares Moses for his ministry, to save Israel. He works as a shepherd in the service of Jethro (Exodus 3:1). There he learns to lead the flock, and after forty years he has to lead God’s flock through the desert (see Psalm 77:20 and Psalm 78:52).
21 And Moses was content to dwell with the man, and he gave Moses his daughter Zipporah.