There are many places in the Old Testament where we can see hints of what is to come, of what God will do in Christ. The life of Joseph is a fine example. Similarities include betrayal for a few pieces of silver, being thrown into a pit/grave, but also the rise to a place of power. And from that place of power, both choose mercy over judgement.