Big discussion on this some years ago. For "pressed" Cd the best advice is store in case on edge. Should last decades. Very high heat/humidity can cause a commercial CD to fail (delamination, mostly) but this is rare.
OTOH, a "burned" CD can fail easily if you expose it to high temperature and/or very bright light. Sunlight inside a car is an example. This can make your CD/R unreadable very fast. You have to keep these at a reasonable temperature, which, in my experience, is the biggest cause of failure of this media. Scratches are obviously bad, too, but I am always careful in handling anything and this is hardly ever my issue. I've had some CD/R's fail that have been left in a computer for weeks and apparently got too hot. Always try a "failed" CD/R in a couple other players if you can---you might be surprised. One player's failure might work on another---this has happened to me often enough.