There are benefits to both the country where the foreign workers work and the countries from which they came.
In terms of the “host” country, the benefit is cheaper labor. In many developed countries, natives do not want to do the hardest, dirtiest, and most dangerous jobs for the relatively low wages that such jobs usually pay. This means that a class of jobs will likely go unfilled unless foreign workers are brought in. Alternatively, the wages for those jobs would have to rise high enough that the price of the product made would end up being too much for most consumers. For example, if people who kill, clean, and cut up chickens were paid high salaries to make up for how unpleasant the job is, the price of chicken would go up a great deal and consumers would buy much less of it.
In terms of the country of origin, the benefit is “remittances.” This is the term for money that is sent home by citizens of the country living abroad. For some countries that have a lot of citizens working in foreign countries, remittances can be a major part of national income. The remittances can be used to boost local economies and move the countries towards a higher level of development.
In these ways, the practice of having foreign workers in a country helps both that country and the country from which the workers came.