Reports of former Egyptian President Mohamed Morsi’s sudden death on June 17 in a Cairo courtroom where he was being tried for espionage for the Hamas terror group centered around his poor prison conditions.

The former Egyptian president and Muslim Brotherhood leader, who was deposed by the Egyptian military in July 2013, had been jailed since shortly after his removal from office. He was charged and convicted of a host of crimes ranging from the deliberate killing of protesters to treason and espionage.

Very few of the details about his actions as president have been mentioned in the sea of reports about his untreated diseases during his prolonged imprisonment.

And that is a shame. For as bad as his suffering may well have been in prison, the suffering that Morsi and his colleagues in the Muslim Brotherhood were inflicting on Egypt and the Middle Was,t and the even greater suffering his retention of power would have inflicted on the region and the world as a whole, was far greater than his private travails in prison.

Today, as tensions rise seemingly by the day in the standoff between Iran and its proxies on the one hand, and Iran’s neighbors, the United States, and Israel on the other, it is important to consider just how much worse things would be today had Morsi remained in office in 2013 and we were now in the seventh year of his rule.

In January 2011, the wave of revolutionary fervor that had swept through Tunisia the previous month came to Egypt. After 29 years of authoritarian rule under President Hosni Mubarak, the Egyptian people seemed to have had enough. Unrest began in Alexandria and Suez, with protests and assaults on police stations, and quickly spread to Cairo. The Obama administration, with the eager support of former Bush administration officials, viewed the unrest with satisfaction. From the Bush administration alumni’s perspective, the popular protests were proof that George W. Bush’s “freedom agenda” was resonating with the peoples of the Middle East. From the Obama administration’s perspective, the revolt against Mubarak, which wa8 led by the Muslim Brotherhood, was an indication that Islamism and democracy were complementary ideals.

Washington was unmoved by the warnings, which grew in intensity during the two weeks of protests that led to Mubarak’s abdication of power on February 8, 2011, from Egypt’s Middle Eastern allies and from Mubarak himself. The Israelis, the Saudis, and other allied governments warned the Americans that the only force in Egypt with the power to replace Mubarak was the Muslim Brotherhood. The Brotherhood, which was formed in 1928, developed the ideology for Sunni jihadists from Hamas to al Qaeda, which it spawned.

Its slogan — “Allah is our objective. The Prophet is our leader. Qur’an is our law. Jihad is our way. Dying in the way of Allah is our highest hope” — left no doubt about its intentions or its planned policies.

And yet the Obama administration closed its eyes and ears to the danger. It disregarded the fact that for nearly 30 years in power, Mubarak was a steady U.S. ally. He studiously maintained Egypt’s peace with Israel and so ensured the prevention of a major regional war. He was also a consistent ally in the fight against al Qaeda. Under Mubarak’s rule, the Egyptian regime was committed to ensuring the safety of the Suez Canal.

Rather than stand by the man that had served as the anchor for the U.S. alliance system with the Sunni Arab world, the Obama administration demanded that he abdicate power while insisting that the Muslim Brotherhood was a positive force.

In testimony before Congress two days after Mubarak was forced from power, James Clapper, then Director of National Intelligence, maintained that the jihadist Brotherhood was “a largely secular” organization that was dedicated to advancing “social ends and the betterment of the political order in Egypt,” in Clapper’s words.

Notably, a week after Clapper’s testimony, the Muslim Brotherhood’s spiritual leader, Sheikh Yousouf Qaradawi, who had lived in exile in Qatar for 31 years, made a triumphant return to Cairo. There he delivered a speech to two million Egyptians at Tahrir Square. He ended the speech with a rousing call for the Egyptians to renew their war against Israel and to conquer Jerusalem. His words were met with roars of approval from the vast assembly.

Qaradawi said, “Egypt, who fought four wars on behalf of Palestine, should not break from this path.”

The ground was set for the Muslim Brotherhood’s takeover of Egypt during the 16 months of the military caretaker government that ran Egypt from February 2011 until Morsi’s inauguration in September 2011. On September 10, 2011 a mob destroyed a concrete barrier protecting the Israeli embassy in Cairo. After hours of siege, it stormed the embassy. Two Israeli security officers were spirited out by Egyptian forces just moments before the embassy was overrun. Saving them required the direct intervention of President Obama, as Egypt’s military regime refused to take calls from Israel’s leaders.

Israel deployed a military transport jet to Cairo airport to evacuate its personnel. Netanyahu referred to the ransacking of the embassy as “a blow to the fabric of peace.”

In 1979 Egypt’s conclusion of its peace treaty on the one hand, and the Islamic revolution in Iran on the other, transformed the two allies into enemies. From 1979 through February 2011, no Iranian warship was permitted to transit the Suez Canal. Two weeks after Mubarak was forced from power, and in a signal to the global community that Egypt’s geopolitical position was rapidly shifting, two Iranian warships traversed the Suez Canal en route to Syria.

In October 2011, Egyptian military forces massacred Coptic Christians in what became known as the Maspiro demonstrations. In the meantime, during the course of the elections campaign, Morsi and other leading Muslim Brotherhood members and clergy insisted that their victory would represent the “second Islamic conquest” of Egypt. Under their rule, the Copts would be treated as second class citizens in line with Islamic sharia law, and be forced to pay the jizya, or poll tax, on pain of death.

After taking power in June 2012, Morsi and his colleagues in the Egyptian parliament set about keeping their promises. In December 2012, they amended the Egyptian constitution in a manner that would have transformed the country into an Islamic state governed by Sharia law, while rendering Muslim Brotherhood rule permanent. In November 2012, Morsi signed a presidential decree proclaiming that his decisions could not be checked by judicial authorities, effectively transforming himself into a dictator.

The month Morsi arrogated to himself absolute power to rule Egypt, Hamas opened a missile campaign against Israel in which more than a hundred rockets and mortars were shot into Israeli territory in 24 hours. Israel’s responded with an eight day counterterror operation called Pillar of Defense. While Morsi played a role in mediating the conflict, he also facilitated Hamas’s aggression. Upon taking office, he opened the Egyptian border with Gaza and allowed the free flow of missiles and other offensive weapons to Hamas, the Palestinian Muslim Brotherhood terror regime. Hamas terrorists, for their part, were deployed to Egypt as shock troops to defend Morsi and his regime. On Monday, when Morsi collapsed in the courtroom, he was being tried for coordinating the January 2011 prison breaks in Suez with Hamas. Morsi and thousands of other Muslim Brotherhood members were freed in that raid, allegedly carried out by Hamas terrorists who had infiltrated Egypt from Gaza.

During his 13 months in office, Morsi also moved swiftly to rebuild Egypt’s relations with Iran. He visited Tehran in August 2012, signaling the shift. In February 2013, he hosted Iranian President Mahmoud Ahmadinejad in Cairo, rolling out the red carpet at the Cairo airport, where Morsi greeted the Iranian leader in an official ceremony.

Morsi would have been successful in his bid to transform Egypt into an Islamic state, had it not been for his incompetence in handling Egypt’s economic crisis. During his short tenure, Egypt’s foreign currency reserves disappeared. As a country that imports half of its grain, its bankruptcy rendered Egypt incapable of feeding its people. And on the eve of Morsi’s overthrow, the Egyptian people were on the brink of mass starvation.

Morsi failed to secure a loan from the International Monetary Fund (IMF), which would have attenuated the crisis because he refused to introduce austerity measures the IMF required.

It was Egypt’s financial collapse that convinced Egypt’s Minister of Defense, Abdel Fatah al-Sisi, to take action to remove Morsi and the Muslim Brotherhood from power. Morsi’s radical Islamist policies terrified the Saudis and the United Arab Emirates who pledged to support Egypt in the event that Sisi and the military acted. Israel, for its part, worked assiduously to block a cut off of U.S. aid to Egypt in the aftermath of Morsi’s overthrow.

Morsi’s rise was the result of a combination of American bipartisan imprudence and Islamist determination and power. Had he and the Muslim Brotherhood successfully retained power, the Egyptian-Iranian alliance he was forging would have mounted a challenge to the Muslim world and to the West that has rarely if ever been contemplated by Western policymakers.

Morsi’s fall was a testament to the Egyptian people’s ability to recognize and correct their mistakes. It was a testament to Sisi’s courage. And it was a testament to the wisdom and willingness to act of the Israelis, and the Sunni Arab states who recognized the danger, even as Washington willfully refused to see it.

It is regrettable that Morsi apparently received ill treatment in Egypt’s prisons. But his failure to maintain power is a blessing for humanity.