Whose feet they hurt with fetters: he was laid in iron:
 Until the time that his word came: the word of the LORD tried him.
In these verses, the psalmist is recalling the story of Joseph. He was one of the 12 sons of Jacob and the great grandson of Abraham. He is the main character in Genesis 37-50.
Although Joseph suffered terribly, it was all part of God’s plan to get the Israelites to move to Egypt. His brothers sold Joseph into slavery. He was later put in jail in Egypt for a crime he didn’t commit. Then he was released from jail, appeared before the king of Egypt and made the second in command in Egypt right beside the king (“Pharaoh”) himself.
With this overall view of the later part of Genesis, consider the following: God could have had the Israelites move to Egypt in a much less dramatic way. God could have just told Jacob (Joseph’s father) to move to Egypt to avoid the famine. So why did God go to all of this trouble in effect to get this one family of Israelites to live in Egypt? I believe it is to show that God is in control of the situations of our lives whether we realize it or not.
Although Joseph was unjustly imprisoned in Egypt due to Potiphar’s wife false accusations (cf. Genesis 39:20), this testing process was like heat that is used to remove dross from fine metal. God tried Joseph and used his imprisonment to bring Joseph to a place of trusting God more in his life.