As the popular hypothesis goes - the Hyksos Pharaohs [the so-called Shepherd Kings] allied themselves with the Hebrews, and when their dynasty was overthrown, the Hebrews were left high and dry - especially since native Egyptians detested shepherds. [Miqqetz 43:32]
There are hints in Vayigash and Sh'mot that support this
In Vayigash, Par'oh asks the brothers about becoming his personal Royal Shepherds [47:6]
And in Sh'mot a new King [dynasty?] arose that knew not Joseph [1:8]
If this mode is true there is a pragmatic lesson here - <drum roll> "Don't put your [political] eggs in one basket."
That is to say, Joseph and his brothers enjoyed ascendancy whilst allied to that Hyksos dynasty; subsequently they were exiled to the political wilderness when their patrons were overthrown.
Simply said, since the Hebrews were unanimously allied to one single party, they were powerless when that party lost power
Something to think about when making "political bedfellows"