What are some examples of mathematics that had unintended useful applications much later? 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. 
 A: A classic example is conic sections, which were studied as pure math in ancient Greece and turned out to describe planetary orbits in Newtonian physics (about 2000 years later).
A: I think a lot of Graph theory was made without thinking about how much applications there are.
One can thing of a city as a graph, where the edges are the streets and the vertices are the crossroads. Now it is interesting for postmen to find ways through the city where avoid walking through a street more than once.
Furthermore it is used for network analysis and here are even a lot more of applications mentioned
A: Von Neumann algebras are special operator algebras, introduced by John Von Neumann who was motivated by problems in operator theory, representation theory, ergodic theory and quantum mechanic. Decades later they found applications in knot theory, statistical mechanics, quantum field theory, local quantum physics, free probability and noncommutative geometry.
A: An outstanding example is RSA public-key cryptography. It is based on number theory, and in particular on the difficulty of decomposing a natural number in its prime factors.
This application is noteworthy because of its ubiquity in Internet secure transactions. It's also interesting that G. H. Hardy, the great mathematician, took pride in the belief that number theory was useless (see "A Mathematician's Apology"), which it has become not to be.
A: Radon Transform is an obscure piece of mathematics which study the integral transform consisting of the integral of a function over straight lines.
This was studied as early as 1917. 
In the second half of $20^{th}$-century, this piece of mathematics find its uses in medical imaging when computer becomes available. It is now widely used in all sort of tomography, to reconstruct the inner image of a patient using scattering data of penetration waves from multiple directions.
Next time when you or your family need to go to a doctor and takes a CT, MRI or PET. You are being benefited by this piece of mathematics.
A: David Hilbert said: "I developed my theory of infinitely many variables from purely mathematical interests and even called it 'spectral analysis' without any pressentiment that it would later find an application to the actual spectrum of physics."
C. Reid.  Hilbert–Courant. Springer-Verlag, New York, 1986.
A: A great example is Pascal's Triangle. Despite being named after Pascal, this arrangement (or others) of the binomial coefficients have been known for at least two thousand years. 
Pascal's triangle turns out to be necessary for the interpretation of NMR spectroscopy data. NMR spectroscopy is the technology underlying the MRI.
And, although I have never seen a biologist use it this way, the binomial distribution is useful for solving the problem that Punnett Squares were invented to solve in Genetics.
A: Matrix theory, which is estimated to have been used theoretically as early as 300 BCE, is being used in making computer-animated movies in order to represent 3D objects on a 2D screen. In fact, I attended a lecture that pointed out that, when Monsters Inc. was being created, one of the biggest challenges the crew needed to overcome was making Sulley's hair move in a realistic fashion. Their inevitable answer involved using transformation matrices!
A: Humans have been interested in knot-like designs for a long time, but knot theory as we know of it began in the 18-th and 19-th centuries. But knot theory wasn't particularly useful for anything for a while - aside from Lord Kelvin's conjecture that atoms are knots in the aether (false anyway), there really wasn't much purpose to studying knots (as far as I know).
Later on, knots turned out to be very important objects in low-dimensional topology; e.g. they often form boundaries of three-manifolds. One can think of the classification of three-manifolds as a difficult problem because it involves the classification of knots, which is challenging in and of itself.
Most surprising though are the ways knots have found themselves applied in recent years: DNA topology and chemistry (people have even synthesized a knotted molecule!) come to mind.
A: "No one has yet discovered any warlike purpose to be served by the theory of numbers or relativity, and it seems very unlikely that anyone will do so for many years."
Written by G.H. Hardy in A Mathematician's Apology in 1940. (Chapter 28, page 140)
A: 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.
A: Haar wavelet, a series of "square shaped" functions that can be used, similar to Fourier transforms, to transform functions into an alternate representation. It had roots as far back as 1909, and at the time was regarded as a mathematical curiosity.
The key characteristics of the Haar wavelet are that it is extremely simple, and when used on image data, the most significant components of a transform also happen to be the most perceptually significant. This mean that it's very useful in image compression. It forms part of the JPEG2000 format, and perhaps more commonly, is used for content-based image searches, such as Google's Search by Image, or "reverse image search". For this purpose, the first usage comes from the paper Fast Multiresolution Image Querying, in 1995. That's a gap of at least 86 years.
There's a more in-depth and not-quite-lay explanation of Haar wavelets here.
A: It is strange that so far nobody mentioned quaternions (discovered in 1843) and their use in computer animation.
A: Non-euclidean Geometries and relativity-theory. When the first concepts of non-Euclidean geometry were developed (like the famous parallel postulate and it's independence from the previous four ones) the majority of people thought that they lived in an Euclidean space let's say. And "exotic geometries" were treated like funny brain-teasers. 100 years laters the first experiments shows that in fact we live in a non-Euclidean space and so subjected to the rule\theorems which was developed hundred years before. 
A: Group theory came out long before it (and representational theory) was used by chemists to model molecular and other structures. Also, computer science was really pure mathematics prior to the advent of the computer. (Yes, computer science existed BEFORE computers believe it or not).
A: Imaginary numbers came out long before their use in electrical engineering became apparent.
A: Boolean Algebra, or the notion that many mathematical concepts can be expressed with variables that only take the values true or false, was pretty applicationless until the advent of the digital computer.
A: All of complex analysis was pure mathematics before it started to be applied to physics. Two examples are Maxwell equations and the Schrödinger equation.
A: Fractal geometry is a wonderful example of a mathematical field that has found broad practical application.  From fractal cell phone antennas to improvements in the diagnosis and treatment of liver disease, to the alien landscapes of Hollywood, fractal analysis and design have become an integral part of modern life.  Here is a link to a page from Michael Frame's site at Yale on various applications:
https://users.math.yale.edu/public_html/People/frame/Fractals/Panorama/Welcome.html
Here are a couple of links regarding liver treatment:
http://www.ncbi.nlm.nih.gov/pubmed/12768879
http://www.fractal.org/Fractal-Research-and-Products/Fractal-properties.pdf
While Benoit Mandelbrot knew that fractal geometry held great promise in many fields, he pursued it primarily for the love of exploration, knowledge, and underlying truth. It's hard to believe now, but his early work introducing the concept of non-integer dimensions was met with derision in some quarters.  One can appreciate the sincerity of his pursuit by considering that one of the last things he had been working on (with Frame) was a theory of negative dimension:
http://www.worldscientific.com/doi/abs/10.1142/S0218348X09004211
In short, given its relative accessibility, fractal geometry provides rich pathways for motivating math students of all ages:
https://users.math.yale.edu/public_html/People/frame/Fractals/BonniePictures/BonniePictures.html
If you'd like, I'd be happy to correspond further regarding the education-based work we did at the NSF-funded Fractal Geometry Workshops at Yale.
Finally, I should mention fractal invisibility cloaks (always a crowd-pleaser), though currently they only work in the in microwave region:
https://users.math.yale.edu/public_html/People/frame/Fractals/Panorama/ManuFractals/InvisibilityCloak/InvisibilityCloak.html
A: Arguably, it's hard to beat the Pythagorean theorem, both on the number of useful applications and how much later they were found.
