He sent a man before them, Even Joseph, who was sold for a servant: 18 Whose feet they hurt with fetters: He was laid in iron: 19 Until the time that his word came: The word of the Lord tried him. Psalms 105:17-19
God knows what He is doing and many times will allow trials in our life to test us. He was preparing Joseph to be a great ruler but he wanted to try and test Joseph first. The Bible says that God sent Joseph ahead. I am sure that when Joseph was a slave he did not think that he was God’s man sent ahead. He probably thought that he was being punished or something like that. You see, many times there is a purpose in trials. We don’t know how God might be using them.