TITLE: Mathematically, why was the Enigma machine so hard to crack?
QUESTION [89 upvotes]: Mathematically, why was the Enigma machine so hard to crack?

In laymen terms, what was it exactly that made cracking the Enigma machine such a formidable task? Everything I have seen about the Enigma machine, from a general article to information about cryptanalysis of the Enigma, is quite lengthy, and it appears to be difficult to pinpoint exactly the most salient mathematical difficulty facing the codebreakers other than the sheer number of possible settings (159 million million million according to this Bletchley Park website) that changed every single day. Or was this really it? There seems to be much more to it than that.
I was hoping someone with a fair amount of knowledge about the mathematics behind the Enigma and its breaking might be able to provide a condensed, simplified reason for what made cracking this machine such a monumental undertaking.

REPLY [6 votes]: The other answers give an idea of the techniques involved but I want to insist on a very deep and confusing observation from the field of cryptanalysis:

Iterated application of very simple (reversible) operations are often very hard to decypher.

In essence, this means that you can take a single operation, say
$$ x_{n+1}\mapsto a\cdot x_{n}+b \mod k$$
and it can be very hard to find $x_0$ given $x_{10000}$ if,say, $a$ and $b$ are unknown. But this is true for almost every operation you can think of ($\mathrm{xor}$, squaring, powers $\mathrm{mod}\ k$, etc)! See e.g. the Blum Blum Shub algorithm or Block Cyphers in general.
The fact is one way functions, or functions $f$ that are hard to invert, are really easy to come up with. Ironically, we don't actually know how to prove that these functions are hard to invert, but they are hard in practice.
Now don't get me wrong: if you write down what seems to be a valid symmetric-key cryptographic algorithm, odds are that you will be vulnerable to some attack that reduces the brute-force search by some order of magnitude, which is why coming up with good crypto-systems is left to experts. But these attacks usually aren't theoretically better than brute-force, in the sense that they still have to enumerate some (exponential) set of keys (but maybe far fewer than the original set of secret keys).
So in some sense, it's not surprising that the creators of Enigma came up with a hard to crack machine: they took this basic template of repeat applications of a relatively easy transformation. What is surprising is that despite this inherent difficulty, Polish and English cryptanalysts came up with reliable ways of cracking this system.