What would it take for this to happen? Baghdad falling and its atrocities being show on social media causing an international uproar pressuring Obama to deploy ground forces? Obama proclaims Iraq won't be another Rwanda.
If ground forces are deployed how much quicker or longer is ISIS defeated? How does this effect the 2016 election?
Its more complicated than that.
For IS to get to Baghdad, they need to go via Husayn ibn Ali's tomb at Karbala. If they get to Husayn ibn Ali's tomb, then a certain amount of explosives are going to be used.
To prevent this happening, Iran will lose as many armour divisions as necessary, because Iran is full of people who don't want to explain to God why they let that tomb be destroyed.
The OTL campaign against IS was essentially fought by the Iraqi Shi'a, Iran, the USAF and the PKK, with some assistance from the Syrian Army and KRG forces, and it worked. There are strong rumours that some of the "international volunteers" for the Syrian branch of the PKK were in fact serving US special forces - and the PKK didn't care that some of their international volunteers sometimes needed alone time in their tent with a radio, as long as the air support turned up as and when it should. There was definitely USMC artillery units committed in direct support of PKK/YPG/etc units in the battle to take Raqqa off IS (*).
If the US was to officially commit troops, then it's pretty straight forward - they commit them in Iraq, at the request of the Iraqi government.
The key concern is therefore the US Senate, who had a decently large contingent of Republicans who were determined to stop Obama getting any sort of success, for fear of how it affects the 2016 election. Solve that, and you can see it happen.
I'd suggest given the attitude of the American Republican Party as regard to faction against country that this will be difficult.
(*) The PKK has spent most of the last 20 years shooting at the Turkish armed forces, and vice-versa. Part of the challenge is making sure the PKK doesn't get given weapons which it saves for use against the TSK later. The compromise is that the PKK doesn't get given heavy weapons, it merely points out target for American air- and artillery-strikes to destroy.