What is the story behind Turkey taking Ankara as its capital, instead of Istanbul?
It's all about the transition from the Ottoman Empire to Turkey. The Ottoman Empire had its capital in Istanbul (or, technically, Konstantiniyye, as Constantinople wasn't renamed officially until the mid 1920s).
Turkey's early dominant man was, of course, Mustafa Kemal, who would later receive the honorific title "Atatürk", 'father of the Turks'. The reason why Atatürk rose to such prominence within this frame of Turkish history was the defeat suffered by the Ottoman Empire in World War 1. The European imperial powers had prepared the Treaty of Sevres, in which they divided the Turkish territories and awarded large swaths of its western territory to Greece - one of the typical divisions of the World War 1 peace treaties, as it was done against the majority will of the local population or at least without inquiring about popular opinion in the affected areas first. The Entente's target was to forever weaken the Ottoman Empire to prevent it from rivalling British and French interests in the Middle East. This was done in three different actions, if you will:
Award large amounts of territory to Greece and Armenia.
Turn Istanbul and its related naval passages - the Dardanelles and Bosphorus - into international zones of control.
Take the Ottoman possessions in the Middle East for the western powers as per the Sykes-Picot Agreement, the British agreement with the Arabs and the British promises to the Zionists. Also, establish a large Italian territory in mainland Turkey to expand Italian influence in the Aegean.
However, with the Great War concluded, the European powers were no longer willing to actually back their words with military action against Turkey, so when the Turks went into military rebellion against the provisions of the treaty, the Greeks were the only military force to stand against them.
Still, Atatürk was concerned about the safety of his national assembly, so he picked a large city centrally located in the Turkish-controlled part of the country and established his parliament there - Ankara. In fact, his initial base of operations was at Erzurum in the east, but he moved it to Ankara precisely to be geographically central within Turkey and, by proxy, closer to Istanbul. Moving the capital directly into Istanbul, which was occupied by the UK and Italy between 1918 and 1923, would have however exposed Turkey's government to potential unforseen reactions from the western powers or, in the worst case, might have resulted in Greece capturing the city during the war and rendering the Turkish government ineffective. Stationing it in Ankara was just safer. There was technically a government in Istanbul ("Ottoman Parliament") - these were the guys forced to sign the Treaty of Severs -, but the rival government in Ankara ("Grand National Assembly of Turkey") was recognized by the Entente, and therefore the treaty rendered ineffective, after Turkish victory over Greece in 1922. Then, the new and improved (from Turkey's perspective) Treaty of Lausanne was signed in 1923, also ending the international occupation of Istanbul. It technically was marked the creation of the Republic of Turkey. Interesting side note: it was also one of the first major acts of foreign policy of a new Italian Prime Minister by the name of Benito Mussolini.
So why did the Turkish never move the capital to Istanbul after the dust settled? Well, there was a population decline in Istanbul at the time where the population hit an all time low of around 500,000 by 1924, down from over a million a few decades before. Also, Ankara was just geographically convenient in its placement. And there is also a symbolic ideological attachment to it - Istanbul is the Ottoman city, whereas Ankara is the city of the Turkish Republic. So they never bothered to move it back.