The following is an excerpt from an email by Moshe Feiglin.
"And it was at that time, and Judah went down from his brothers." (From this week's Torah portion, Vayeishev, Genesis 38:1)
This verse opens the entire story of Judah and Tamar, which took place after Joseph was sold to Egypt by his brothers. Our Sages in Breishit Rabbah have an interesting perspective on the events described in these verses:
"The tribes were preoccupied with the selling of Joseph, Joseph was preoccupied with his sackcloth and fasting, Reuven was preoccupied with his sackcloth and fasting, and Jacob was preoccupied with his sackcloth and fasting and Judah was preoccupied with taking a wife and the Holy One, Blessed Be He was busy creating the light of Mashiach."
Read full article: http://www.jewishisrael.org/eng_contents/update/5771/7110.htm#Mashiach