As a region, not a political unit, Afghanistan “was always part of somebody’s empire, beginning with the Persian Empire in the fifth century B.C.,” according to Boston University's Thomas Barfield. Afghanistan has been conquered and occupied continuously “for 2,500 years.”
From Cambridge University, Andrew Roberts writes:
The reason that Alexander stayed in Afghanistan so briefly was that there was so little to keep him there, in terms of wealth or produce; he went to Afghanistan to pass through into India. Afghanistan had already been conquered by the Median and Persian Empires beforehand, and afterwards it was conquered by the Seleucids, the Indo-Greeks, the Turks, and the Mongols. The country was quiet for most of the reigns of the Abbasid Dynasty and its successors between 749 and 1258. When Genghis Khan attacked it in 1219, he exterminated every human being in Herat and Balkh, turning Afghanistan back into an agrarian society. Mongol conqueror Tamerlane treated it scarcely better. The Moghuls held Afghanistan peaceably during the reign of Akbar the Great, and for well over a century afterwards.
When Alexander took Afghanistan, he wasn't taking it from the Afghanis, but rather from the Persians. And when it ceased being part of Alexander's empire, it became part of the Seleucid Empire. There is no phase of independence. In fact, the very name "Afghanistan" was inflicted on the nation by outside conquerors, when the peaceable inhabitants were forced by invading Muslim armies, after thousands of them had been executed merely as a show of power, to accept Islam as the state-imposed religion.
Hardly any of these empires bothered to try to impose centralized direct power; all devolved a good deal of provincial autonomy as the tribal and geographical nature of the country demanded in the period before modern communications and the helicopter gunship. Yet it was they who ruled, and the fact that the first recognizably Afghan sovereign state was not established until 1747, by Ahmad Shah Durrani, illustrates that the idea of sturdy Afghan independence is a myth.
The government of 1747 didn’t last long, as Afghanistan was part of the British Empire during the 1800’s. Despite stories of a British defeat in 1842 with 16,500 casualties, the Afghanis didn't offer any substantial resistance to the English. The reality was that the casualties were mainly non-British, and the few British who died were the victims of the commanding officer's stupidity. In any case, the English hold on the territory wasn’t loosened. Andrew Roberts continues:
For all the undoubted disaster of Britain’s First Afghan War, the popular version of events is faulty in several important respects. It is true that 16,500 people died in the horrific Retreat from Kabul, but fewer than a quarter of them were soldiers, and only one brigade was British. The moronic major-general William George Keith Elphinstone evacuated Kabul in midwinter, on Jan. 6, 1842, and the freezing weather destroyed the column as much as the Afghans did; one Englishwoman recalled frostbite so severe that "men took off their boots and their whole feet with them." Wading through two feet of snow and fast-flowing, freezing rivers killed many more than jezail bullets did, and despite Lady Butler’s painting of assistant surgeon William Brydon entering Jalalabad alone on his pony, in fact several hundred — possibly over a thousand — survived the retreat and were rescued by the punitive expedition that recaptured Kabul by September 1842. Early in 1843, the governor-general, Lord Ellenborough, sent Sir Charles Napier to capture Sind, and thereafter Afghanistan stayed quiet for 30 years. Sir Jasper Nicolls, the commander-in-chief of India, listed the reasons for the defeat at the time as: "1. not having a safe base of operations, 2. the freezing climate, 3. the lack of cattle, and 4. placing our magazines and treasure in indefensible places."
So the 16,500 casualties turns out to be actually less than 4,000 - and instead of one lone survivor, there were many. Of those who did die, the causes of death were not combat-related, or even war-related. But the real bottom line is that English dominance remained. The tales not told are of the 1880 battle, for example, in which the British army suffered almost no casualties while retaining control of Kandahar.
After the 1747 government's brief independence, the next real shot at having their own state was in 1919:
After 1880, in the words of Richard Shannon’s book The Crisis of Imperialism, “Afghan resistance was subdued and Afghanistan was reduced to the status virtually of a British protectorate” until it was given its independence in 1919.
Although independent again for several decades, it was rather unstable - a long string of assassinations kept the government rather shaky. Finally, the Soviet Union occupied it for several years, and when they left, the Taliban would be the next invader.
The lesson: although the Taliban imposed a harsh cruelty on the Afghani people, they were simply the most recent power to occupy the nation. While the Taliban were brutal foreign rulers, the contrast between the Taliban and previous eras of Afghani history is not that the Taliban were foreigners who established their rule over Afghanistan, but rather than they were ruthless in doing so. Afghanis have been accustomed, for centuries, to not having their independence and being part of someone's empire, but Taliban's Islamic severity set them apart from previous imperial governors.