As you pointed out, when population begins to decline, immigration is necessary to maintain the balance of the country. Basically, you need immigrants to fill all the vacant jobs.
So there's nothing wrong with immigration in and of itself. It's when you have a massive influx of people who aren't adapting to the society or learning the language that you have a problem. And the reason why they haven't adapted to the society is because greedy politicians have made it possible for them to survive without doing so. Politicians generally just care about getting re-elected. They could care less about the long term effects that their decisions will have on the country.