Through trial and error a formula was developed through which the wavelengths in the visible spectrum of hydrogen could be reproduced. When attempts were made to apply this formula to the spectrum of atoms with more than one electron, it did not work. The wave theory of light could not explain the line spectra of excited gases. Classical Newtonian Physics, which worked for moving automobiles, planets, etc. couldn't generate the Balmer Equation. The red glow of the toaster wire, the red glow of the stove heating element.
Black cars get hotter in the summer sun than white cars.
The wavelength distribution depends on temperature. Planck tries to understand the relationship between intensity and wavelength of emitted light from hot objects. The then prevailing laws of physics could not account for what was observed. Planck made a daring assumption. Energy can be absorbed by atoms only in chunks of some minimum size.