I'm having trouble with
Rayleigh's law about black-body radiation. What was exact wrong with it?
One underlying idea of black body radiation is that it can be well modeled as a large enclosure with a pinhole for the output energy. Such a large enclosure will effectively have an infinite number of allowed cavity modes, effectively because it is very very large. There are more modes with higher frequency. With a small aperture (pin-hole), the radiation will bounce around, get absorbed by the walls and then re-emitted off the interior walls until there is a thermal equilibrium. Then, the small amount of radiation leaking out of the pin-hole from the inside will not drain the internal energy but will emit a spectrum that is representative of the black body emission.
So, there are two issues with Rayleigh's law. First, it assumes that all modes are filled and will have equal thermal energy, which is just an assumption. That's not even a reasonable assumption because the integrated energy then becomes infinite (hence the ultraviolet catastrophe). Also it assumes energy is a continuum, which is a very reasonable assumption given the knowledge at that time.
I'm sure Planck looked at the equal energy assumption as incorrect, but he no doubt was not initially questioning the idea that energy is continuous in such a system (this type of system is basically modeled as a collection of harmonic oscillators, which seems to be a recurring theme in physics, including quantum field theory).
Planck eventually realized that energy must be quantized as E=nhf, where, n is an integer, h is Planck's constant and f is frequency. Combining this with the idea that the distribution of modes with energy should not be equal, he could think of the thermal energy of the cavity needing to fill up the lower energy states allowed by E=nhf. Plank was able to work out the actual energy distribution based on the assumption that energy is quantized, and it happened to match experimental results.
So, you can see that physicists often just make assumptions, and make a prediction from that. Then they see how well it works. In Releigh's case, everyone of that time believed energy is continuous, and then he assumed that modes were equally distributed because that seemed to be true in his work on thermal capacity. But, it didn't work. Planck, assumed energy is quantized, and that was his creativity to consider that possibility when no one else would accept such a silly idea. Even he did not know what to make of his discovery, but then Einstein came along and made the next step. Then, others continued and developed the quantum theory that has been so successful.