A little intro here: I am Brazilian, and until recently I worked for a government agency that handles grants and general money distribution for college-level (undergrad and above) projects, research and scholarships. I can speak with a decent level of certainty about the relationship between Brazil and other countries on this regard.
First of all, let's get some things out of the way.
The first of them is an incorrect idea that when we talk about exchange programs, or students going to study overseas, we're talking of people who'd be in the lowest community colleges going to Ivy-League colleges in the US. That's simply not the case. The US schools require SATs, money guarantees and an array of extra information, tests and guarantees that American students do not require, as expected. The problem with this part is that it's most often than not, not accurate. The TOEFL for example, does very little to enforce a good output level of skill in English. It kind of ensures that the person _understands_ English, but writing and especially speaking it.. Yeah.
The second thing is that most students going from Brazil to other countries (and the US is the top choice) are part of at least 1 of 2 groups: Either they are from wealthy families and have had much above-average education throughout their entire lives, and therefore are usually just as good or often better than natives in the country they've chosen to go for higher education; or they are outstanding students (no matter the background) and earn their sponsoring through good grades, outstanding projects or simply put, what Obama called "being brilliant."
The third point is that, at least for Brazil, it is by no means "free." (and this is where my previous employment at that gov agency comes in.) A Brazilian student looking to go, for example, to the US for college, has 3 options:
1) They pay for it on their own (the wealthy family example I cited before);
2) The institution they are going to sees in them such an awesome potential that they sponsor it, much like they would with a native getting scholarship;
3) The Brazilian government (via agencies such as the one I used to work for) sponsors it, paying for it with Brazilian tax money.
Numbers #1 and #3 are obviously not free by any means, I believe that's clear. You could argue that #2 is "free" in the sense that the US is paying for it, and I'd agree with you if I didn't know some specifics of that deal. Here it is.
Countries around the world, and the US is probably the strongest one on this matter, enforce a rule about "exchanging students" in situations like #2 above. The way it works between a developed country, and the US in specific, is somewhat "exploitative" against developing countries like Brazil. Usually, US schools demand a ratio of X:1 (where X >= 1) to accept a Brazilian student under those circumstances. In exchange, Brazilian schools will have to accept X American students under similar conditions, and it's usually for Masters or PhD programs. In the end, the US still gains in the trade, because more American students come to Brazil to get higher-level education than Brazilian students get to go to the US for undergrad programs.
Another point to be cleared here is the fact that while Brazil does not have any schools standing at Ivy-League level of recognition, we have several, several schools that are good enough to be considered better than the alternatives right below Ivy-League. So at this point we need to remember that not everyone can be in an Ivy-League school. Most people end up going to "average" schools or below that "threshold". So in the end, coming to a top school in Brazil ends up being better than the alternatives they could face in the US, and that's not even taking into account the life experience of living in another country, learning another language, etc.
And yes, in the end, foreign students also come here "for free", get better education than most natives can get, and go back to their home countries with extra cultural and educational experience. It's not an exclusive thing in the US, the US is just under a brighter spotlight.