"He sent a man before them - Joseph was sold as a slave" (Psalm 105)
Remember his marvelous works which He has done, His wonders, and the judgments of His mouth.
He then recounts God's works to Abraham, Isaac, and Jacob, saying:
When they went from one nation to another, from one kingdom to another people, He permitted no one to do them wrong; yes He rebuked kings for their sakes.
Well, yes, but when we read the fine print, it didn't really look that way from day to day. Abraham had to fear what Pharaoh would do to him, and more so, too, because of his own folly (Genesis 12). Isaac found himself being robbed again and again of wells that his father had dug, wondering when they would let him keep his own (Genesis 26). Jacob had his daughter seized and raped at Shechem, and then had to be afraid that all would gather against him because of how his sons avenged this insult (Genesis 34). And finally, God drove them out of the land with famine. He had sent Joseph before them to prepare the way, but not so elegantly - his own brothers had sold him there as a slave, so that God rescued them by means of their own malice.
Then God freed them from Egyptian bondage. But that didn't feel too glorious to begin with:
He turned their heart to hate his people, to deal craftily with his servants.
That's a pretty harsh way for the salvation of God to turn up in your life!
But that's the way it is.