Many books have been written explaining the teachings of the Ari on the subject of gilgulim (or gilgul neshamot), "reincarnation." These books explain when and how reincarnation takes place and give details regarding many soul-roots and how we find them reincarnated in the Bible and afterwards in the time of the sages, and even up to the time of the Ari himself.
The Ari traced the gilgulim of archetypal souls from Adam until his own generation and explained that in addition to the purpose of rectifying blemishes of previous lifetimes, each successive incarnation is in order to manifest and rectify a new, different dimension of the same soul.
According to the teachings of the Ari, Adam becomes David who will finally be reincarnated as the Messiah, as indicated by the fact that the initial letters of Adam David Messiah (alef, dalet, mem) spell Adam. All were contained within the soul of Adam. Similarly, the three letters that comprise the name of Moses, Moshe, (mem, shin, hei) stand for the initials of Moses Seth Abel, the three primary incarnations of this archetypal soul from future to past.
The Ari was able to reveal to his disciples their past incarnations so that they would be able to rectify the blemishes of the previous lifetimes in this one and continue to reach new and higher levels of consciousness.
According to the Ba'al Shem Tov, it is not necessary to reveal this information to every individual. Sometimes knowing our last life history can be detrimental to our rectification in this life. This knowledge can confuse the mind and not allow us to be open to achieve good in a simple and pure fashion; thus, that kind of knowledge can narrow our consciousness as opposed to broadening it.
It is important to understand that in Judaism reincarnation is in no way cruel or fatalistic, as may be found in other traditions. Judaism instructs us to always be concerned to change the reality of this world for the better. For a Jew, the world in which we live exists and has meaning and purpose. Indeed, all of the worlds were created for the sake of this world, in order that by our good deeds we make this lowest realm of existence a dwelling place for the Infinite One, blessed be He. Every successive incarnation is another chance, enjoying new input of Divine energy, to succeed in one's holy mission on earth. In the end we will all succeed in this mission. Helping another succeed in his life's mission is an intrinsic part of one's own success.