At the moment when Adam and Eve ate from the Tree of Knowledge of Good and Evil, the "Revolving Sword" also came into existence. This sword guards the passage between the Heavenly Garden and this earthly existence. Some people call this sword the "Flaming Sword" - because it whirls with such a brilliant, blinding light that it seems to be on fire. But it should more properly be called the "Sword of Transformations", because it changes one thing into another. The Revolving Sword slices both ways - good and evil, evil and good - but it also mixes them up.
In this earthly world, it is not always easy to tell what is evil and what is good, because when they pass the Revolving Sword, they are finely chopped together. Our job when we incarnate here is to sort the wheat from the chaff - the good from the evil - to set things right again. When this great work is finished, the universe will be in balance once again, and the Moshiach will come.
But this work is not so easy, because our souls are also mixed up in this world. Between the Revolving Sword and this earth plane is the "Hall of Exchanges", where souls can become switched in their destinies. Some souls make it through the Hall and into their properly designated bodies, but others do not. That is why it can happen that the "garments of skin" we wear here might not reflect our true spiritual natures: "There are righteous men who are reached according to the deeds of the wicked, and wicked persons who are reached according to the deeds of the righteous." (Ecclesiastes 8:14)
It was because of the Hall of Exchanges that our saintly father Abraham was born into a family of sinful idol worshippers. But he could not remain in his birthplace, the city of Ur, because his soul was driven to seek the One True G-d. He was born into a house of idolatry, but his soul did not really belong to it.
And so it has continued throughout history, among rich and poor, among rulers and those who are ruled. A person such as Napoleon, who was born a mere peasant, might really have the soul of a king. Or the crown prince could have the soul of an ignorant peasant. A Torah scholar can be born of illiterate parents, a sinner can give birth to a saint, a Jew can return as a gentile.... nothing on earth is really as it should be. And thus it will continue, until the Great Work is done and the Moshiach comes, to set all things right again.
"Jewish Tales of Reincarnation" by Yonassan Gershom