I guess it is not strictly necessary, but it brings in a lot more money, which the university is of course very eager to take.
Tuition is one of the few levers left, and while people will object to tuition hikes for in-state students, very few people will do the same for foreign students.
It's devastating when you learn so many of society's problems are due to this.
In my experience, the large influx of foreign students are typically at the masters level. MS classes are typically (not always lol!) more advanced than undergraduate classes. So, you need more qualified instructors, such as your tenured/tenure track faculty to teach them. When you take T/TT faculty out of undergraduate classes and replace them with teaching faculty, you lose a lot. (Let me know if you need what's lost to be spelled out.)
Today they are bloated with administration that is nothing but a cost center, meanwhile they eliminate tenured professorships and have classes taught by tenuous adjunct faculty who are paid poverty wages. Universities could easily right the ship by cutting the administration and focusing on teaching and research, but the people who need to make the decision to do that are the ones who would be cut.