Theodor Fontane did not write "Das Trauerspiel von Afghanistan" in 1847/8, as the Berlin Review of Books erroneously claims, but a decade later.
By that time, Fontane had been twice been in London as a foreign correspondent for Prussian newspapers: the first time from April till September 1852 (Bemmann: 99-106) and the second time from September 1855 till January 1859. The occasion for the second time was the Crimean War, in which Prussia did not want to intervene (Bemmann: 113–131).
(Fontane had developed an interest in England in the 1840s, reading, for example, Hume's massive History of England and the works of Walter Scott. England and Scotland had been important sources of inspiration for his ballads.)
By the end of his second stay in England, his admiration for the British people was at its nadir. He described the English as a "money-making Volk" and was especially appalled by the massacres during the Indian Rebellion of 1857–1858. In a letter to the editor-in-chief of the Neue Preußische (Kreuz-)Zeitung (his employer), he wrote that, with regard to India, all of England disgusted him; he even described the English as a people of "robbers and pirates". (In spite of his criticism of English colonialism and English society, he did not condemn the English people as a whole.)
It is perhaps this historical background and his criticism of colonialism that inpired him to write "Das Trauerspiel von Afghanistan". (I have been unable to find statements about a specific explicit motivation to write this poem.) According to the entries in his diary, he worked on the poem on 1 and 2 May 1858; he recited the poem for the literary society Tunnel über der Spree (in Berlin) on 3 April 1859. It was printed in the magazine Argo in 1860 (Tagebücher: 616). Before April 1859, Fontane had already recited the poem in London on 5 August 1858 (Berbig: Theodor Fontane Chronik: 905) and for the literary society "Krokodillen-Gesellschaft" in Munich on 10 March 1859 (Berbig: Theodor Fontane Chronik: 962).
- Bemmann, Helga: Theodor Fontane. Eine preußischer Dichter. Ullstein, 1998. (440-page biography published on the occasion of the 100th anniversary of the author's death; now out of print.)
- Berbig, Roland: Theodor Fontane Chronik. De Gruyter, 2010. (Day-by-day chronicle of Fontane's life and works, based on the author's correspondence and diaries, and other sources; 3.905 pages.)
- Fontane, Theodor: Tage- und Reisetagebücher: Tagebücher 1852, 1855-1858. Edited by Charlotte Jolles, Rudolf Muhs, Gotthard Erler and Therese Erler. Aufbau-Verlag, 1995.