TITLE: What are some examples of mathematics that had unintended useful applications much later?
QUESTION [102 upvotes]: I would like to know some examples of interesting (to the layman or young student), easy-to-describe examples of mathematics that has had profound unanticipated useful applications in the real world. For my own purposes, the longer the gap between the theory and the application, the better.
My purpose is to explain to the people I know why studying theoretical mathematics isn't a waste of time, and more importantly to motivate students. The reason I would like to have a longer time gap is that I want it to be clear that the mathematicians could not possibly have had the future applications of their work in mind.
A good example of this is Robert Lang's TED talk about origami, in which he describes how origami artists applied circle packing to their own work to construct designs, and how later engineers used origami to construct devices that can be transported compactly and then unfold to fill a larger space. His premier example is that of transporting large telescope lenses into space; since they are made of glass, they have to be carefully folded, and not just stuffed into a canister.
Other examples are how number theory was developed and later used in cryptography, and how polynomials were studied and later found to be useful in all sorts of applications. These have drawbacks, however. Cryptography and its uses in computer science are basically still math, and it's quite complicated. It's also not so clear that people studying polynomials weren't aware of their many potential applications.
Are there other good examples that fit my criteria? I think the latter two examples I mentioned could also be good examples, if presented correctly, but I'm not sure how best to go about that (and I am most interested in hearing of other connections).
Edit: If my motivation (or its wording) bothers you, please just ignore it and instead note that surprising later applications and connections make for interesting and engaging talks.

REPLY [4 votes]: This is an extension to ricardo's answer on non-euclidean geometry and general relativity.
I just want to add to his answer that the independence of the fifth Euclid's postulate was a well-known open problem for over 2000 years. In fact, the beginning of non-euclidean geometries were motivated by attempts to prove the independence of the fifth postulate by contradiction ("assume it doesn't hold..."); however, no contradiction was found. 
It is also noteworthy that already Gauss (100 years before Einstein) tried to do physical experiments to test the fifth postulate by measuring angles and distances in many-kilometers-large triangles; he was probably one of the first who realized that the Pytagorean theorem (as well as the "sum of angles in a triangle=180 degrees") doesn't need to hold in the "real space". (He was not able to disprove it with his aparatus, just derived a very small upper bound on possible deviation from these theorems based on his measurements) 
As for the applications, today the general relativity theory based on non-euclidean computations is not only used in space-missions but also in satelitte navigation: that means, in GPS systems, broadcasting, flight navigation... It is very likely that at some point, it is used to deliver this text to you.