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.