Before I start, I want to first acknowledge the fact that hindsight is 20/20. I don't think anyone could have predicted things would have turned out this way.
After 9/11, there were clear links the Taliban in Afghanistan were harboring Bin Laden and Al Qaeda. For example, it is widely believed that Ahmed Shah Massoud (the leader of the Northern Alliance and the Taliban's major foe) was assassinated by suicide bombers mere days before 9/11 to cement the alliance between Bin Laden and Mohammed Omar. However there are no such obvious links between Bin Laden and Saddam Hussein.
I still don't truly understand why we invaded Iraq, or why that invasion was sold so heavily to the US public and the world by the Bush administration. He didn't have WMDs, nor any links with Al Qaeda. Yes he was a despotic tyrant, but those exist all over the world and we do nothing about the others. The toppling of Saddam's regime left a massive power vacuum in Iraq, the consequences of which we are still dealing with today.
In response to the American occupation of Iraq, a group of Sunni militants was formed under the leadership of Abu Musab Al Zarqawi. Though they have been known by many names, I'll refer to them as AQI (Al-Qaeda in Iraq). They should be thought of a separate group from Bin Laden's Al Qaeda however. Though AQI swore allegiance to Bin Laden, their radical ways proved to be a public relations problem for Al Qaeda. Zarqawi's penchant for public beheadings and killing fellow Muslims alienated a large portion of the Iraqi population. The American airstrike that killed Zarqawi therefore actually removed a thorn from Bin Laden's side.
The reason why I bring up this whole story is because the current Sunni militant group ISIS is the direct descendent of AQI under Zarqawi. Their rampage through Syria and Iraq is a result of the 2003 invasion of Iraq. Saddam ruled with an iron fist, but that fist ultimately kept all of these ethnic and religious tensions in check. Removing him from power led directly to the rise of ISIS.
Finally, I think all of these problems are ultimately tied to the issue of loyalties in the Middle East. The Iraqi army was supplied and trained by the US, but they fled from a much smaller invading ISIS force because of their lack of loyalty to the Iraqi government. It seems to me like people in that area of the world have much more loyalty to to their own religious and ethnic groups than to some nationalistic invention like the Iraqi government. That's why Shia militias have rallied in eastern Iraq to fight ISIS with the backing of Iran's Shia government (despite the fact that they fought a brutal war against each other in the 80's), and why the Kurdish Peshmerga stands as the only real fighting chance of pushing ISIS back. ISIS is loyal to the Sunni sect and their self-proclaimed Caliph. The Kurds are loyal to Kurdistan. The Baathists are loyal to the Baathists. And the Shia are loyal to their own religious sect. No one is fighting for the idea of a united Iraq encompassing all of these factions.
Maybe we shouldn't either.