I've had similar questions over the years, and did some research on this. Let me admit, though, my interest comes from a different angle. I was originally thinking why didn't the USSR invade Turkey somewhere around 1939 - 1941?
But I will try to answer your question about why Germany didn't do it.
There's a phrase I know that goes something like this: Good generals study tactics, but really good generals study logistics. So let's have a look at a topographical map of Turkey (click for higher resolution):
As you can see, it's very mountainous. In that respect, it's similar to Afghanistan. A war here would be very different from the war in flat East Europe. That does not mean it's impossible, but it would take a lot longer than normal.
Turkey's area is about 783 thousand square kilometers (303 thousand square miles). This would actually be the 2nd largest country in Europe, if you considered all of Turkey to be part of Europe. (The largest, of course, is Russia---even if you only consider EuroRussia.)
Population of Turkey in 1940: 17.8 million. From this we can estimate that the number of males aged 15 to 35 is about 2.37 million.
From the mountainous regions, you would think logistics would be a nightmare too. However, the immediate question is, were there any railways in Turkey around 1940?
And the answer is yes. I found a great site, trainsofturkey.com, that has a lot of historical info on this.
First the 1914 map:
This is actually not too bad. If you can blockade the coasts and use the pink railway, you could surround practically the whole country.
From some more data and maps on that site, especially this table, I was able to construct a map to show what railways existed in 1941:
Dark Red lines I confirmed existed by 1941. Bright Red lines I could not confirm exist by 1941. Even so, you can see that there is a decent network of railways throughout most of Turkey.
Unfortunately, I could not find any data about which lines, if any, were double-track (2 lanes dedicated for 2 directions). I could not find what gauge these railways are, but I think they're almost certainly the "Standard Gauge" (1435 mm) used by Britain, France, Germany, and many other places. But probably, the tan line in the northeast is Russian Gauge (1524 mm).
The point of those rail maps is to show that, theoretically, logistics is not as bad as it might seem from the topological map. This is of course contigent on having access to those railways, the rolling stock, and not being interfered with by the British Navy, for example. We'll get to those again soon.
We also need to know the state of Turkey's military at this time. For this I rely on Wikipedia's Military History of Turkey. It does not appear comparable to Germany's military, nor to Russia's military for that matter.
Finally, we need to know Turkey's economic role in the war. AFAIK, the only economic product of importance was Chromium. Chrome is an important alloy for stainless steel. Without it, your steel would rust. I could not find maps of historical chrome mines in Turkey, so I don't know exactly where those mines were located.
So the most logical invasion plan would probably go something like this:
Invade Thrace (European Turkey, west of the Bosphorus) to set up airbases and control the Bosphorus Strait.
Blockade and bombard the coastal cities and towns. This would require sea power, which Germany didn't have in this part of the world. Britain had almost all the sea power in the European Theater, and note that Cyprus has a major British Naval Base right next door.
Alternatively, use air power to bomb the coastal cities/towns and ports. This is no small matter. Assuming your airbases are only in Greece, Bulgaria, and Crete, the distances involved probably mean that only the west half of the coast is feasible to bomb.
Anyway, somehow clear a beachead and get access to at least one railway, I would guess at Istanbul or Samsum. Then import rolling stock to move your army into the interior. If Germany could get access to a railway, this is feasible. Germany could certainly produce its own rolling stock (train engines, train cars, etc.), and there appears to be a rail connection to Istanbul from Greece or Bulgaria.
Fight your way in along the railways. Set up army bases and airbases along the railways. Even if the railways are one lane only, I believe this is feasible. I'm pretty sure the Russian Civil War, at least, saw some heavy fighting on single-lane tracks with armored train cars. Another matter is sabatoge (blowing up tracks or trains). From what I've read, however, track can be repaired in less than a day when you're prepared for it (bring repair equipment on your train), and clearing a wreck takes maybe a day too. I believe Russian practice in WW2 was to put a dummy car at the front of a train to take the brunt of any mines anyway.
Preferably, invade the valleys around Adana and Iskendrun to get access to the relatively flat lands on the Syrian Border. This will cut off access routes. Remember, Syria became part of Vichy France but then was retaken by the allies in summer of 1941, along with Iraq right before it.
So why didn't Germany do this?
In some sense, they were alreadying trying to access the Middle East or Transcaucasus, but through Africa, presumably because the terrain was easier.
Turkey was a neutral supplier of Chrome and historically had good relations with Germany (like in WW1). Keep in mind that Spain, Portugal, and Sweden were also neutral suppliers of critical materials. If Germany invaded Turkey, those others would get pretty nervous and may have more incentive to join the Allies.
Something else to note: The Molotov-Ribbentropt Pact agreed that the USSR would annex all of Finland, even though Finland had important nickel mines. This shows that Germany was willing to allow important resources in future enemy hands, so by that reasoning, they should be perfectly willig to allow important resources in neutral hands too.
Russia was the bigger threat---much, much bigger---and conquering it would give Germany a lot more than Chrome. In fact, we should look at the order of conquest that Hitler did, or tried to do: Poland, Denmark and Norway, France and Benelux, Britain, Southeast Europe, Russia, The End. Most of those were real threats. Turkey was not a threat.
If Germany invaded Turkey, Britain would almost certainly ship in war supplies. Turkey would almost certainly allow British troops to come and help them defend. This would probably include aircraft too, and the Battle of Britain and the Blitz were aerial defeats of the Luftwaffe by the Royal Air Force. Britain' Navy would almost certainly secure most of the coast, with the exception of the Black Sea. Britain could resupply Turkey indefinitely as long as Convoys kept coming from America and Canada.
When Germany conquered the Balkan Peninsula, it was a very bloody victory. The British were helping Greece at the time, ensuring large casualties for the Germans. They could expect more of the same if they tried it in Turkey.
When USSR invaded Finland in 1939, they did not succeed. This made Finland lean towards the Axis, and they allowed Nazi troops into Finland. Hitler probably did not want to risk such a thing happening in reverse in Turkey.
So to sum up: Invading Turkey could only be realistically considered if Germany could somehow do it "one at a time" like they did with Czechoslovakia and Poland. Even then it would have cost a lot of casualities and time. By 1940, the gig was up and Britain was at war with Germany.
The bigger threat was Russia, and Hitler actually believed Russia would die by the end of 1941, giving him access to oil in the transcaucasus. No need to go after non-threats unless somehow you knew they were about to side with the allies. Turkey was pretty committed to neutrality, and German intelligence probably knew this.
Disclaimer: I am not an expert in war or geopolitics. But I have read a lot about Germany and Russia in WW2, and their decision-making.