Grad school programs in the US are pretty good. People come from all over the place. Students from other countries (UK, Europe, Australia) are usually better prepared than their US counterparts. The US education system isn't so much uniformly "bad", it's just quite variable. Some students take first year grad courses in their final year and come out with a very strong background, but others are taking 9th grade math in college.
Some students also come over because it's a reasonable path to immigration, so even if the programs themselves weren't very good, being in the country can open doors.