So we find, that from the time a person is born via a gilgul (because he required reincarnation), the entire Nefesh with all of its parts reincarnate with him there (into his new body). However, the purpose of the gilgul is not [to benefit the parts of the Nefesh that were already rectified but perhaps can still benefit from rectifying a minor aveira], but rather, [the rectified parts of the Nefesh] are only there to help the new body [to do the specific mitzvos] (with the purpose of rectifying those specific parts of the Nefesh that were blemished) from a serious aveira that was committed in a previous body (thus requiring gilgul).

And, dependant on [whether he rectifies the specific serious aveira in this gilgul] determines whether he is rewarded or punished (in this life). However, the other rectified parts of the Nefesh (which came with him into this new body) do participate in the reward that he receives from his mitzvos, but they do not receive punishment from his aveiros in this new body (because they come into him having the status of an Ibur).

So here, when this Nefesh (the person in this new body) suffers issurim (hardships) or punishments which come to him in this new body in this life (the 'theme' of his life and its hardships usually are related to the part of his Nefesh that needs fixing). So whatever hardships or tragedies he suffers in this body are related to what he did to his Nefesh or the sparks of his nefesh in the previous body [to cause him to require reincarnation].

Also, (it is possible that he was reincarnated only for death, because) death itself is a big 'tzar' (suffering), so too what happens after death is also a tzar. But through this tzar (or the hardships in his life), these atone for what he did in previous bodies (in previous gilgulim). At the same time, the mitzvos that he did in previous gilgulim, and also the sparks [which were created or previously elevated through mitzvot performed in a previous body], these sparks come with him and join him now in this gilgul, and he has these sparks (and the rectified parts of his Nefesh) which take part in his tikkun (of the serious aveiras he committed in a previous gilgul).

However, if in this body he continues to sin, or if he increases in his aveiros and doubles and adds onto them, you might think that there will be no end to his needing reincarnation! But, since the rectified parts of his Nefesh that come with him, and the sparks from his previous gilgulim join him with the status of an Ibur, they are not affected by the aveiros he does in his life; they only are benefitted by him if or when he does any mitzvah in this body.

So from one gilgul to another, to another, he eventually rectifies his Nefesh and the sparks one spark at a time. And through this, he eventually finishes the need to reincarnate, because he has completed the tikkun (rectification) of his Nefesh. So through this, he completes his Nefesh, and rectifies all of his netzitzut (sparks) through his reincarnations. This continues until he completes his gilgulim and he rectifies all of the nitzutzot (for each body part) from the head of the Nefesh to the feet of the Nefesh.

And when he finishes the rectification of the sparks in his feet, then Moshiach will come to complete [I assume the entire body of] Israel, as is explained in the Zohar, Parshat Pikudei, page 258, and in the end of Parshat Vayakhel.