ויהי בעת ההיא וירד יהודה מאת אחיו
The Midrash Tanchuma explains the juxtaposition of Yehudah’s marriage, upon the loss of his wife and two sons, and upon the incident of Yosef’s sale, with Yehudah being the one to inform Yaakov Avinu of Yosef’s death. Hashem said to Yehudah, “You have yet to father children; thus, you do not know what raising children and losing them means, the accompanying pain and sorrow. Yet, you were the one to inform your father that a wild animal had killed/torn his son apart. You must now experience the pain of losing a child. Therefore, you will marry and father two sons,…