Well into the 20th century, virtually all of Africa was dominated by rapacious Western colonial powers. Somalis put up a vigorous fight but eventually fell to British and Italian imperialism. Britain took control of Italy’s portion of what is now Somalia after WWII, giving away parts of Somalia to Ethiopia in 1948, just before the UN allowed Italy to resume control with a trusteeship.
As Africa decolonized, France, controlling “French Somaliland” (later Djibouti), rigged a referendum, expelling thousands of ethnic Somalis to prevent a result in favor of it joining Somalia. In addition, four days before it granted independence to its Somali holdings in 1960, Britain allowed the Northern Frontier District (NFD) of Kenya, then a British colony, to be run by Kenyan nationalists despite a vote that had showed the overwhelming desire of the region’s population — mostly ethnic Somalis — to join the new Somalia.
Throughout the 1960s, Somalis in Kenya’s NFD rebelled and faced harsh, violent repressions, Kenyan forces killing and relocating many. The rebellion ended after a few years, but violent Kenyan state repression against ethnic Somalis persisted heavily until 2000. When Italian Somaliland was freed just days after British Somaliland was freed they united to form a Somali Republic that only last until 1969, when its president was assassinated and General Mohamed Siad Barre took over in a coup d’état.
Gen. Barre morphed Somalia over several years into an Islamic communist state. As part of a Pan-Somalism vision, in 1977 Somalia initiated a war with Ethiopia to take the regions that Britain had given to away to Ethiopia, taking much territory. The Soviet Union was patron of both countries as Ethiopia was newly communist, but when Soviet mediation efforts failed, about 1,500 Soviet military advisers and 18,000 Cuban troops arrived to help push the Somalis back in 1977-1978.
After being abandoned by the Soviets, Somali became partners with the U.S., which helped Somalia to build the largest army in Africa. Yet over the 1980s, the government became more totalitarian and oppressive, and both militia and political resistance movements arose, partly encouraged and supported by Ethiopia. When Barre’s government collapsed in 1991 along with any form of central government, northern Somalia became autonomous and the rest was fought over by various militias.
As Somalia became totally destabilized and a humanitarian crisis ensued, three UN peacekeeping missions — UNOSOM I, UNITAF, and UNOSOM II — were deployed from 1992-1995, the last of which saw the infamous Black Hawk Down incident in Somalia’s capital, Mogadishu, in which 18 American soldiers were killed (that’s what people remember today, but the missions still saved hundreds of thousands from starvation and shouldn't be called a failure).
As the state wholly disintegrated, a variety of local forms of government filled the vacuum, and in many areas, Islamic sharia law courts arose, providing justice governance and militias. As they spread they started integrating, forming the Islamic Courts Union (ICU) in 2000. Over time they came into conflict with secular warlords, from May to June of 2006, ICU took complete control of Mogadishu. In just a few months, ICU controlled most of southern Somalia, prompting a Bush-Administration-backed Ethiopian invasion of Somalia that drove ICU out of power that December.
Young extremists from ICU gradually broke away after this defeat and formed al-Shabaab. Starting in January 2007, the U.S. began drone, air, and sea-based strikes against terrorists (including al-Shaabab) in Somalia and pirates off the coast, strikes which are still ongoing. Al-Shabaab and ICU carried out a bloody insurgency (including suicide bombers) against Ethiopian troops, subsequently deployed African Union (AU) forces, and the fledgling Somali government. But after Ethiopia withdrew, al-Shabaab rose to control most of Somalia’s south by 2010.
In retaliation for Ugandan participation in AU operations, al-Shabaab carried out suicide bombings in July 2010 against crowds watching the World Cup Final in Kampala, Uganda’s capital, killing 74 people. Al-Shabaab even banned many aid groups in its territory during a catastrophic famine, making its effects far worse. After al-Shabaab cross-border raids inside Kenya, Kenya invaded a neighbor for the first time in its history in October 2011 to go after al-Shabaab in Somalia, while al-Shabaab pledged allegiance to Al Qaeda, even as it was driven out of Somalia’s major cities. By June 2012, independent operations were over and remaining Kenyan units became part of the African Union force.
Knowing all this, is it any surprise that al-Shabaab struck outside of Somalia again, even recruiting Americans and maybe Brits to take part in an attack on a posh Kenyan mall in response? Already since that attack, al-Shabaab has attacked Kenyan towns on the Somali border.