I'm not an expert on the subject, but from what I understand, both failures are due to quantization of energy states. The Rayleigh-Jeans law, if I remember correctly, can be derived by realizing that the inside of a blackbody is like an infinite square well and taking into account rules about how an ensemble of bosons behaves.
An ideal gas should have a specific heat of 6/2 kB classically speaking, and this shouldn't be dependent on temperature. The reason is that the average of something that contributes quadratically to the total energy (i.e., 1/2 m v^2_x, 1/2 I \omega^2, 1/2 k x^2, etc.) is always 1/2 kB T. However, in quantum mechanics, the angular momentum contribution to the kinetic energy no longer has the form specified above. I forget what the form is exactly, it's somewhat complicated, but the important part is that, while the average of the classical angular momentum contribution is proportional to T, the average of the quantum mechanical angular momentum contribution is proportional to something else, probably T^4 (yielding a T^3 dependence for the specific heat).
So, to sum it all up, the quantization of energy states in an infinite square well is responsible for the Rayleigh-Jeans law, and the quantization of angular momentum is responsible for the temperature dependence of the specific heat.