The Vilna Gaon opens his commentary on Sefer Yonah by identifying Yonah as an allegory for the human soul: just as Beur HaGra on Yonah, Hakdama 1 explains, the soul is sent into this world to repair it (tikkun), and if it fails — and indeed damages itself in the process — it is sent back in a second gilgul to complete that repair, though it does so in pain on account of its misfortune.
Elaborating on the opening verse, Beur HaGra on Yonah 1:1 describes the soul's mission as God sending it into a particular body and commanding it to do His will, and notes that the soul is called "Yonah" — the dove — whether in its first gilgul or its second, whether its return goes well or ill.
The soul that fails to complete its correction does not rest: Even Sheleimah 10:32 states that after undergoing whatever suffering it must, the soul is brought to Gan Eden and from there sent into a gilgul to straighten what it had crooked.
The Gaon draws a striking conclusion from this about the relative value of life and death: Even Sheleimah 1:5 explains that Kohelet's praise of "the dead who have already died" over "the living who are still alive" (Kohelet 4:2) refers precisely to those who completed their tikkun in their first life and did not need to return in a gilgul, compared to those who must return — and this also resolves the Gemara's ruling (Eruvin 13b) that it would have been better for a person not to have been created.
Building on that same teaching, Beur HaGra on Yonah 4:3 understands the dispute between Beit Shammai and Beit Hillel as a disagreement about gilgul itself: those who say it is better for a person to have been created hold that each gilgul brings additional mitzvot, while those who say it is better not to have been created hold that it is preferable to have completed the tikkun in the first life without needing to return — and the Gaon rules in accordance with the latter view, concluding that the essential purpose of one who returns in a second gilgul is to correct the sins of the previous life, not to accumulate new merit.
To help a person identify what he damaged in a prior life, Beur HaGra on Yonah 4:3 offers two signs: the area in which a person stumbles repeatedly in this life, and the transgression toward which his soul feels an especially powerful craving — the craving itself being evidence that the soul grew accustomed to it previously and it became second nature.
The Gaon also accounts for why a righteous person may suffer: Even Sheleimah 3:6 and Beur HaGra on Yonah 4:1 both explain, drawing on the Zohar, that one who was wicked in a first gilgul and is now righteous is nonetheless brought low by God — the moon receiving diminished light from the sun — and so remains in want all his days despite his present righteousness.
Underlying the whole structure is the relationship between soul-components: Even Sheleimah 1:12 teaches that the ruach comes into the world to give life to the nefesh, and that all the punishment of the ruach is on account of its failure to repair the nefesh — reinforcing that the entire mechanism of gilgul is oriented toward completing what the soul left unfinished.
The imagery of the great fish that swallows Yonah is decoded by Beur HaGra on Yonah 2:1 as the grave itself and the angel Dumah who presides over the dead, while the three days Yonah spends in its belly correspond to the three days during which the soul hovers near the body before departing — anchoring the allegory in the soul's experience at the threshold between death and its next journey.