The OP question is right on.
People come here primarily for economic opportunity.
Remove the economic opportunity by making the people virtually un-employable, and the problem mostly solves itself.
Longer term, we could try to encourage/invest in the countries south of us to provide much of the manufacturing we rely on China for today, just a matter of national security; but also with the benefit that the more opportunity available in those countries, the more stable they become, the less incentive people have to come to the US.
The right hasn't lately wanted to solve the issue because then they want to campaign on it.
The left hasn't lately wanted to solve the issue because the far-left are sympathetic to the immigrants, particularly asylum seekers (whether legit or not is another story).
Neither side has wanted to solve the issue because it is generally good for business - cheap labor for undesirable jobs, etc.
Neither side will work with one another either, which makes solving any problem impossible.
If we actually desired a coherent immigration policy we would fix the verification system, and then determine some form of work visa program for the jobs we actually can't fill domestically, and we'd basically know/control exactly who was coming in. People would not have incentive to come illegally because a) they could not find work and b) there would be a legal path where they could get work.