Simple answer? Do what some other countries used to do.
Unless you have a desirable skill of some kind (high education, military experience (leading/commanding), and so forth) don't let the immigrants in.
This will sound A-loggish or even dickish. My idea:
Advertise: "You can come to our country if you pass a series of tests, they will be presented to you in your native language. If you fail them, you will be deported or executed should you resist deportation."
Needless to say, give a study-guide beforehand. Let them stay in a center to study it for up to a day or three. Systematically call the immigrants into testing facilities.
Have the test consist of simple questions such as adhering to the culture of the country in question, penalties for breaking major laws (rape, murder, theft, littering - the latter being the major issue with the immigrants), and so forth.
In short, give them a chance. Even if they pass it, only give them up to two months of government assistance - adequate time to find a job. Cut it off if they do not find one.
On immigrants, also have a MUCH MUCH less tolerance policy. You break a major law (anything more than 30 years in prison), you're dead. You break minor law, you get the max penalty for it - no questions. You don't get a slap on the wrist. You are a full-grown adult, have come into a country that is not your's, and have committed a crime. You are expected to act like a human being. If you do not, you will be punished.
In the case of illegal immigration? If one is found to have a fake passport, is on government assistance, or something of the like without having been accepted in the county? Death sentence immediately. No 'deportation' as that costs money for the country in general. You broke a sovereign country's border in an attempt to get access to its resources. You are not a 'desperate' person. You are classified as an invader. No life in prison - as you will be costing money, food, and space.