There is one thing that differentiates CDs, however, from the media that preceded them — print or photographs on paper, camera film, magnetic tapes, etc. CDs store information in digital form, and that makes all the difference. Let me explain, using audio recordings as an example.
When a voice is recorded onto a old-style magnetic tape using analog electronics, some amount of noise goes onto the tape as well. It's inevitable even with the best, most expensive electronics; the noise comes from fundamental random processes of physics. The universe is full of this noise and, in some respects, could not exist without it. The noise is random, and there is no way to remove it once it's there. So, what goes onto the tape is the desired voice plus noise. As the tape ages, the magnetic signals impressed into the iron particles get weaker. The result is that noise increases when the tape is played back 30 to 50 years later. Again, because the incremental noise is random, there is no way to remove it.
Electrical engineers have been dealing with this phenomenon for 100 years, and they've developed some clever ways to minimize the impact of noise. You've heard the name Dolby, I'm sure. But they cannot make the noise go away.
So what's different about a digital recording? Before going onto the storage medium, the signal is converted to binary format... ones and zeroes. Lots of them, done in a very rigid manner, but still just ones and zeroes. These go onto the CD. Yes, there is noise, but despite the noise there are only two possibilities during playback: a one or a zero. It takes an awful lot of noise to change a specific zero into a one or a specific one into a zero. And when this does happen once in a blue moon, there is an additional technique called forward error correction that allows many of these playback errors to be detected and reversed. Voilà, the ones and zeroes are retrieved exactly as they were originally impressed — despite the inevitable noise.
This ability to regenerate a clean signal with near-perfect accuracy from a slightly degraded digital medium or channel is one of the things that make digital technology so useful. Think of it as cheating death, in a way, or resisting the inexorable universe. It has its limitations, and it's not cheap, but it's much more resilient than the analog alternatives.
My advice, however: re-record your CDs and DVDs every 10 years or so.
As to whether today's file formats like JPG and MPG will still be decipherable in 100 years, I believe so. I have confidence in the desire and ability of future generations of software designers to preserve our legacy. Note, however, that whenever you have a choice between a "lossless" storage format and a "lossy" storage format and you want the material to be retrievable in 25+ years, always choose the lossless format or the least lossy format. I mention this because JPGs and MPGs use data compression. Although your eye may not easily see the loss of data as a consequence of its being compressed, or your ear may not hear it, data is being lost in the process. This is different from a lossless compression like ZIP files. A ZIP file can always be put back the way it was. That's not necessarily true for JPG and MPG. Worse, re-encoding the file in a different standard that is also lossy can compound the problem. There is something to be said for data storage in "raw" format — and the prices of hard drive storage have been falling for 50 years with no end in sight.