The US government and much of the punditocracy interpret these developments as a "problem" for which a "solution" must be found. They are wrong. This is part of the natural disintegration of a state which has no basis for its existence.
The Middle East includes some of the world's oldest nations, such as Iran and Egypt, but Iraq is not a nation and never has been one. Except for the centuries-old eastern border with Iran, its borders are an arbitrary construct of Anglo-French imperialism after World War I, enclosing three groups of people who don't like each other and have no feeling of common identity.
Iraq's population is about one-fifth Kurdish (in the northeast), one-fifth Sunni Arab (in Anbar province and extending north to the edge of the Kurdish area) and three-fifths Shiite Arab (in the remaining southeastern part of the country). Baghdad is a mix of all three groups, since people from all over tend to settle in the capital. The Kurds are a distinct people with a language closely related to Persian, not at all related to Arabic or Turkish. They are also Sunni, though that fact is not very important. Kurds also live across the borders in Turkey, Syria, and Iran; their land, informally called "Kurdistan", is a coherent territory divided among those four states.
Saddam Hussein was a Sunni Arab, and his regime brutally repressed the Shiites and Kurds. His genocidal al-Anfâl campaign of 1986-1989, to thin out the Kurdish population, destroyed about 4,500 Kurdish villages, displaced a million people, and killed about 180,000. This helps explain why the Kurds, having gained de facto independence, are determined not to be drawn back under the authority of the Iraqi state.
President Bush foolishly though that overthrowing Saddam would usher in democratic nationhood in a place where neither democracy nor nationhood have ever existed. In fact, all it did was to reverse the power relationship between Sunni and Shiite. Democracy means Shiite dominance, since Shiites are the majority. Prime Minister Nouri al-Maliki's government, much to US frustration, has operated as a Shiite regime, excluding and denigrating Sunnis -- not surprising since, to the Shiites, the Sunnis are not fellow countrymen but former oppressors.
Al-Qâ'idah, a Sunni organization which has massacred Shiites when it had the chance, plunged into the chaos of post-Saddam Iraq when it saw a chance to position itself as the defender of the Sunni minority there. Since then, the country has seen endless tit-for-tat terrorist attacks between Sunnis and Shiites. The current main Sunni militant group ISIS ("Islamic State in Iraq and Syria") consists of people who were expelled from al-Qâ'idah for excessive brutality, which gives you some idea how difficult they are to deal with. Outsiders were shocked this week when the Iraqi army melted away without a fight when attacked by a smaller and less-well-equipped ISIS force. I wasn't. ISIS fighters are motivated by religious fanaticism which has repeatedly shown its power to move men to kill or die for the cause. The Iraqi army is under orders to defend a fake state that nobody believes in.
This was inevitable once the US pulled out. A foreign power defending the integrity of the Iraqi state is like plowing the sea -- as soon as you stop, what you think you accomplished instantly disappears. ISIS is now threatening to march on Baghdad and seize the Shiite holy cities of Najaf and Karbalâ; it's been suggested that US airstrikes could stop this, or perhaps the Iraqi army will fight harder when defending Shiite territory. Iran (also Shiite) might even intervene, though after the massive losses of the Iran-Iraq war, public enthusiasm there for an actual invasion would be low to say the least.
ISIS probably can't conquer the Shiite southeast, or at least not much of it. But even if the US committed a big enough force to help the Iraqi government re-take Anbar province and the north, the situation would simply revert to something like the present one as soon as we left. Saddam held Iraq together with brutality and terror which were shocking even by Middle Eastern standards. That option isn't available any more, not to any government that wants to avoid his pariah status. Neither the Shiites nor the Sunnis can establish stable control over the whole country.
And the Kurds? They have little interest in Iraq beyond their northeastern enclave, but their Peshmerga fighters have protected the independence of that enclave not only against the feeble post-Saddam state but against Saddam's much stronger forces during the last few years of his rule. They've now seized Kirkuk pre-emptively to protect it from ISIS, and can probably hold it against them, too, even though the Iraqi army which the US helped create failed utterly. They're fighting, not for a fake state, but for their own people. Because -- and this is the important point -- whatever the maps tell you, Iraq is not a nation, but Kurdistan is.
Update 1: Iran has intervened to support fellow Shiites against ISIS, so far on a fairly small scale.
Update 2: This excerpt from The Guardian, I think, sums up the US role well:
The sheer scale of the Iraqi military's capitulation in the face of a well-armed and disciplined insurgent force has shocked American soldiers and officers who fought in Iraq. Many were involved in training and mentoring Iraqi counterparts and left the country thinking they had helped build a credible institution, perhaps the only one in the land. "When I arrived in 2003, I was a true believer," said a former US marine. "I voted for Bush, I believed in the cause. Then I stayed for three years. We were lied to. We went there for nothing and we came away with nothing. It cost a trillion dollars for this?"
Even after such a huge investment by a superpower, the artificial state is crumbling in the face of the enduring realities of religious fervor, Kurdish nationalism, and Iranian power.