Staying in Iraq to bolster democracy, keep jihadis down, and reducing Iranian influence were important jobs after the kinetics. We screwed up by being out from 2012 until ISIL overran large chunks of Sunni Arab-majority Iraq in the first half of 2014.
Staying in Iraq since defeating ISIL's caliphate has been a slow victory over Iran:
The government and Iraqis in general are particularly keen to retain American troops in Iraq, to discourage Iran from trying to take over the government by force. Elections and opinion polls show Iran is losing support and the Iranians are desperate to turn that around and do dangerous things as part of that effort. Iraqi government efforts to stop the verbal threats to American facilities and forces as well as the actual violence are hampered by the fact that while a shrinking minority of Iraqis support Iran those supporters still occupy key political and security force jobs.
We are at war with Iran--as the Iranian missile/drone attack on Saudi oil export capacity shows vividly. We aren't waging a lot of the war kinetically, but it is a war.
And Iraq is one of those fronts. It is a front that we can win--if we wage the battle. It doesn't take many Americans in Iraq to bolster Iraqi will to resist the Iranian influence. But this will take time.
Let me add that I am relieved that our small force in Iraq (plus allies) today is enough to work against Iranian influence. I certainly felt that much more was needed in 2011. I was apparently wrong back then to think we needed 25,000 American troops to defend the win. Although the ability to push back Iran's influence since 2017 when the ISIL caliphate was dismantled in Iraq doesn't mean necessarily that I was wrong in 2011, I suppose.
[I clarified the last paragraph and added a link I meant to include in the first sentence.]