The Iraqis are more comfortable with having American troops remain after the defeat of ISIL than they were in 2011 after the defeat of al Qaeda, Iran's hand puppets, and remnant Baathists, and recognize our importance in rejecting Iranian influence:
Iraqi leaders were under a lot of political pressure from Iran to ignore the American sanctions [on Iran], if only because complying would hurt the Iraqi economy. That pressure caused some hesitation by Iraqi leaders until they realized that most Iraqis preferred the Americans to the Iranians. After all, when Iraq asked the Americans to leave in 2011 they did. Iranians are not very cooperative in that respect and for centuries have been trying to get its way in what is now Iraq.
In January 2012 (optimist that I am), after we proved we'd leave when told, I hoped that the Iraqis would feel secure enough to ask for American troops to return to Iraq:
So are the Iraqis, after demonstrating that we will pull out our troops when told to do so, agree to a return of some American troops?
Sadly, the Obama administration had no real interest in going back. That is, until June 2014 after ISIL spent the first half of the year taking western and northern Iraq, defeating the Iraqi military that rotted away as leadership was chosen for loyalty rather than competence. Then we launched Iraq War 2.0 to restore the victory.
The Iraqis paid one Hell of a price from 2014 to 2017 to learn that America is not interested in staying in Iraq forever to control the place. But they did learn that lesson.
I hope Trump isn't the one who has to learn the lesson--again--of why we should stay in Iraq.
UPDATE: A useful history of links.