What is discrete?
What does it mean to be discrete? That means that there is a first energy level, a second energy level, a third, and so forth, but nothing in between. If energy levels were continuous, we would expect there to be infinitely many energy levels in between, just as there are infinitely many fractions and between one and two. Since the energy levels are discrete, they're more like whole numbers--there is no whole number between one and two. The word "quantum" itself means the smallest distance between two different discrete values.
The fact that energy levels are discrete is incredibly important to physics--starting with atoms. Atoms are made up of a tiny, massive, positively charged nucleus, and a light, negatively charged electron. If it weren't for quantum mechanics, the electron would lose all its energy, radiating it out as light, and would spiral into the nucleus. All this in a fraction of a second, and you can kiss chemistry goodbye (or rather you couldn't, because your atoms would have collapsed). However, thanks to quantum mechanics, there is a lowest energy level for the electron. The electron cannot go any further below the lowest energy level, no more than there can be a positive whole number below 1. Next time you see Quantum Mechanics Personified, you should thank him or her for your atoms.
When inventing a physical theory, it's not enough to just say, "Energy levels are discrete". Sure, that's nice to know, but we also want to know what those precise energy levels are, and why they are. I won't go through the historical details, but the answer to the why is Schrodinger's Equation:
Now, if you were familiar with complex numbers and differential equations, all I would need to tell you is what all those symbols stand for, and you would eventually go, "Ohhhh! It makes sense now." Well, maybe. But I will not assume that my reader even knows how to read the equation.
Schrodinger's equation basically predicts the behavior of what we call the wavefunction. A wavefunction is like a particle, and like a wave, but it is neither a particle nor a wave. It's a wavefunction. What the wavefunction represents is the probability of finding the particle in any particular location. For example:
If this were our wavefunction, we are most likely to find the particle where the hump is. But there is a good chance that the particle will be slightly off to the side, and a very tiny chance that it will be very far away from the hump.
The wavefunction can actually be negative too. Though a negative probability is impossible, I neglected to mention that the probabilities are equal to the wavefunction squared. A negative number squared is positive, and positive probabilities are okay.
But what isn't okay is a positive probability greater than one. It wouldn't make sense, for instance, to have a coin that has a 2/3 chance of getting heads and a 2/3 chance of getting tails--we can only get one result per coin flip. The total probability must add up to exactly 1. What this means is that we can't have a wavefunction that increases indefinitely as we get further from the "hump". A wavefunction that increases indefinitely is called a non-normalizable wavefunction--a wavefunction that cannot possibly have a total probability that adds up to 1. Non-normalizable wavefunctions are impossible, by common-sense probability.
Most particles fit into two categories: free particles and bound particles. For example, a photon emitted by the sun into space is free. A particle that you trap between two walls is bound. An electron that is attracted to a nucleus is also bound. When we say that a particle has discrete energy levels, we actually mean that a bound particle has discrete energy levels.
I will consider the particle trapped between two walls, and describe the appearance of its wavefunction, as determined by the Schrodinger's equation. I am considering this as a 1-dimensional problem, ignoring the possibility that the particle will go above or around the wall.
Outside the walls, the wavefunction is very small, and gets closer and closer to zero as we get further from the center. However, note that the wavefunction isn't quite zero. That means that there's a small possibility of finding the particle on the other side of the wall! This is called "Quantum tunneling". However, note that this is only on a very small scale, with tiny particles and extremely thin and soft walls. Otherwise, the chance is so unlikely you're better off waiting for a miracle.
Inside the walls, the wavefunction is wavy. It goes up and down, alternating between positive and negative. How many times does it go up and down? That depends on how energetic the particle is. But you can be sure that it goes up and down a whole number of times. It can't go up and down one and a half times. If you tried to make it go up and down one and a half times, it would hit the wall midway through a hump. The end result would be a non-normalizable wavefunction which increases indefinitely outside of the walls.
Here's what the first few possible wavefunctions look like:
[I must admit to taking this from the Wolfram Demonstrations Project]
As I said, the amount which the wavefunction goes up and down is related to how much energy there is. The more times the wavefunction goes up and down, the higher the energy. But the wavefunction must go up and down a whole number of times. Therefore, the energy can only have discrete levels! The same is true for any bound particle.
More to it
I admit there are a few more details that I haven't yet mentioned.
For instance, I neglected to mention that there are a limited number of possible wavefunctions for any bound particle. If the particle has too much energy, it will simply escape from the walls. Furthermore, if these are electrons then there can only be one electron per wavefunction. The electrons will form a sort of stack, with one electron in each energy state. That's why a nucleus can only hold a certain number of electrons (this number depends on how many protons are in the nucleus).
Furthermore, the "free" vs "bound" dichotomy isn't so clear cut. If we are studying an electron that escaped from its atom, it may be free from the atom, but it's still trapped in our lab. If we just consider a large enough space, almost any particle can be thought of as "bound". But as the region of space gets larger, the discrete energy levels become closer. Soon they will be so close together that the energy levels would appear to be continuous for all practical purposes.
There's more! Wavefunctions don't just stay motionless the whole time. And then we have "mixed states." Further explanations are upcoming!
Update: I wrote more on mixed states.