ISIS provided what the government and the private sector couldn't provide, a paying job. That's what the Iraqi insurgents did when Bremer disbanded the military and fired anyone with ties to the Baath party. He didn't even make allowances for those who had to join to get their jobs. He then prohibited Iraqis from starting businesses that might compete with American businesses. They went so far as to importing foreign workers and materials for reconstruction. 70% unemployment was the result
Another big mistake was not disarming the military before disbanding them. They also forgot to secure the ammo dumps. Many of the IED's were made up of what was culled from these storage compounds.
The decision to withdraw was made in 2008 under a SOFA agreement with Iraq. Obama tried to amend the SOFA to keep a security force there, but Maliki would not agree to legal protections for US soldiers. So we withdrew under the conditions of the 2008 SOFA.
Those refugees had to have money to get out of their country, so the poor and uneducated are stuck because they can't bribe/pay for safe passage. These people will work hard to prove they are worthy/grateful to the host country.
Germany is accepting refugees because they need young workers to make up for their aging population. With Finland cutting education, they may need these young educated workers.
The best book on programming for the layman is "Alice in Wonderland"; but that's because it's the best book on anything for the layman.