I believe the standard explanation of the phrase that “the land will vomit out its inhabitants” is that the people will go into exile (see for example, Rashi on 18:28, quoting the Sifra and the Targum). 18:25 and 20:22 are then warnings to the Jewish people not to sin since they would be punished with exile.
Threats of punishments for sins are recorded towards the end of the book of Vayikra 26:14-43, and one of these threats is that the people will go into exile if they sin, 26:33,34. I have heard (do not recall from whom) that the punishment of the land vomiting out people differs from the similar punishment of exile in chapter 26 that the punishment relating to vomiting is an automatic exile from the land, while the punishment of exile as recorded in 26:33,34 is dependent on G-d deciding to send the people into exile.
Does the metaphor of vomiting really correspond to the idea of people going into exile? Even if a person vomits immediately after eating, still around half of the food remains in the body. Thus, if a person wants to understand that the land vomiting means that the land will somehow force the people into exile (low agricultural productivity?), this can only mean that half the people will go into exile, which significantly reduces the warning not to sin. Note in this case in Vayikra, one cannot say that the land of Canaan had low agricultural productivity at this time since the spies brought fruit that was enormous, Bemidbar 13:21,27.
Another difficulty with the idea that the metaphor of the land vomiting means that the people will go into exile is that 18:25,28 seem to explain that the Canaanites were vomited out the land of Canaan, but the Canaanites were still living in the land, as the end of 18:24 records that the Canaanites will be sent out of the land when the Jewish people come to the land.
With regard to the last difficulty, the Ramban (end of comments on 18:25) explains that the vomiting can refer to going into exile and be referring to the Canaanites since once G-d had determined that the Canaanites were to be exiled, then it is like it already occurred. A variation of this idea is that a friend of mine, Ram Elboim, suggested that since the Jewish people were about to enter the land of Israel (if there had not been the sin of the spies), so then one can understand that 18:24,28 are saying that the Canaanites are being thrown out in the present, which would include the upcoming months.
David Hoffmann (1953, vol. 2, p. 23) notes that since the Canaanites were still living in the land of Canaan/ Israel when G-d was speaking to Moshe, then it cannot be that the metaphor of vomiting means that the people will go into exile. Instead, he notes that before people vomit, they feel uncomfortable, and then the idea is that the vomiting by the land is referring to a stage where the land is making the people on the land feel uncomfortable (again, low agricultural productivity?) prior to the people being thrown out of the land (or leaving on their own?).
A different idea is that the vomiting signifies a partial exile, like a partial spewing out of food, and a partial exile could mean that while the people were living in the land, they were not the legal owners of the land. With this idea, once Avraham captured the land from the four kings (Bereshit 14:14,15), he became the legal owner of the land of Canaan. The Canaanites remained in possession of the land and lived in the land (like squatters), but they were no longer considered the legal owners of the land. With this idea, the vomiting out of the Canaanites in the past would refer to the Canaanites losing their legal ownership of the land, and then the threat of the Jewish people being vomited out in the future is that they would lose ownership of the land, which would mean that they would be living under the control of other people and/ or living with an ever-present threat of being expelled. This threat is different than the threat of exile in chapter 26, and hence the Torah uses different terms to describe the different punishments.
A variation of this third approach with regard to the Canaanites is that for approximately three hundred years the Egyptians controlled the land of Canaan/ Israel, 1468 BCE to 1140 BCE (?). Thus, the Canaanites had been ruled by a foreign ruler for quite some time or were still being ruled by a foreign ruler depending on when chapters 18 and 20 were told to Moshe. This could be the reference to the Canaanites who had been vomited out in the past in 18:20,24, as in the past, from the perspective of the time when the book of Vayikra was told to Moshe, the Canaanites had experienced a partial exile of living under foreign Egyptian rule.
This idea also accords with another aspect of vomiting since when people vomit, they are not in control of themselves, as usually the body forces them to vomit, and if a foreign ruler has control of the land, then the people are forced to do what the foreign ruler decides. The warning to the Jewish people of being vomited out in the future would then be that they would sin in the future, then they would lose control of the land of Canaan/ Israel, even if they still would be living in the land of Canaan/ Israel.
Bibliography:
Hoffmann, David Tzvi (Germany, 1843-1921), 1953, Leviticus, (Hebrew), Jerusalem: Mossad Harav Kook.