I know of events like the Great Game between Russia and Britain, The War in Afghanistan by the US, etc. However, I've never understood why people have been fighting over Afghanistan all throughout history.
I would disagree with the statement that people have been fighting over Afghanistan "all through history". Afghanistan has not seen territorial wars at any greater frequency than its neighbours. Rather, Afghanistan has variously served as a buffer state between great powers, or a convenient staging ground.
The modern nation state of Afghanistan is divided diagonally by the Hindukush mountain, which served as the defacto dividing line between two great historic cultural influences: Persian & Indian. North of the Hindukush were lands under the Persian sphere of influence. It is believed Zarathustra was born somewhere in this region, and held an important position in the Persian worldview. South of the Hindukush were the lands of Gandhara, an ancient Indian kingdom and one of the 16 mahajanapadas of ancient India. Gandhara was so strongly a part of the ancient Indian ethos that it housed the university town of Taxila, the traditional centre for the education of young princes and nobles from across ancient India.
Being on the edge of the Persian & Indian world, this region was regularly swept up in the ebb and flow of empire. Cyrus the Great captured the lands south of the Hindukush till the Indus, and incorporated into the Persian province of the Indus. The Indian provinces of the Persian empire were the richest and most populated by far, and provided the most tax revenue. These provinces were later occupied by Alexander, only to be traded by Seluceus to the Mauryan empire in return for war elephants. The Hindukush served as such an effective border that lands on either side were rarely part of the same empire. The Indo-Greeks, the Kushans, the Indo-Parthians, the Sythians, the Huns, and the Hepthalites were just some of the kingdoms that would use these lands as a staging area for a greater Indian empire. The key to military access into India was control of the mountain passes.
The Hindukush mountains served to prevent the passage of ancient armies into the rich desirable lands of India. There are two mountain passes into India, the Khyber & Bolan passes. Control of these passes meant a convenient choke point for militaries. The Khyber pass is today in Pakistan, just a few kilometres from the Afghan border. It was through these passes that the Turks, the Afghans, and the Mughals would march into India. The Mughals would fight hard to control these passes and their Afghan holdings. The British would later ensure in the treaty with the Afghans that these passes remained in British India.
Afghanistan (together with Khorasan, which has historically included parts of modern Afghanistan (and Iran and Turkmenistan)) is an important crossroads for land-based trade in Eurasia. Afghanistan connects India, Persia, and Mawarannahr/Transoxiana, and through them Mesopotamia and the Mediterranean and Black Sea and on to Europe, and China. This made it valuable real estate.
Being valuable real estate isn't enough for neighbouring countries to fight over it for so long. Real estate that can be easily conquered tends to end up as part of its neighbours (perhaps to be traded from neighbour to neighbour in wars), rather than an independent country or region that is fought over. If it is powerful, it can be the one to invade its neighbours. Things that helped Afghanistan be fought over for so long include being difficult to conquer, and not being powerful enough to grow against powerful neighbours.
However, most of this was various countries trying to conquer Afghanistan. There hasn't been much of other countries fighting each other for the control of Afghanistan. This is a more modern phenomenon - the Great Game was not like past fighting for control of Afghanistan. For similar to the Great Game, consider Mongolia, with China, Russia, and Japan fighting for dominance (with rather more active warfare than the Great Game, but there was plenty of time when the maneuvering was diplomatic rather than military). Prior to this modern struggle, Mongolia was frequently a battleground, but more usually between different Mongolian groups, of Mongolian groups and neighbours - the case of Great Powers fighting each other over it had to wait for Russian expansion to gobble up Siberia, and the Japanese to have a suitable foothold on continental Asia. Again, in Tibet, we see fighting between the Dzungar Mongols and the Qing (resolved in favour of the Qing, with their conquest/destruction of the Dzungars).
Other areas have been extensively fought over, with outside powers fighting each other, before the modern period. A notable example is Syria/Palestine, fought over by Mesopotamians, Egyptians, Byzantines, Crusaders, Mongols, and Turks (and in modern times, by Ottomans and Europeans). A gateway between Egypt and Mesopotamia and Anatolia, Asia and the Mediterranean, it was attractive real estate. In much of this fighting, it was attached to one of its neighbours, but for some, was mostly held by local rulers.