This comes from Planck's Law, i.e., the quantization of the electromagnetic field.
The shortcut derivation from semiclassical arguments, following mostly Planck's original derivation, goes as follows. First you start counting the number of modes in a frequency interval [itex]\mathrm{d} \omega[/itex] of electromagnetic waves. To this end think of a cubic volume [itex]L^3[/itex]. Only waves with wave numbers [itex]\vec{k} \in \pi/L \mathbb{N}^3[/itex] "fit" into the volume. The corresponding modes are given by
[tex]\vec{E} \propto \sin(k_1 x) \sin(k_2 y) \sin(k_3 z),[/tex]
fullfilling the boundary condition that [itex]\vec{E}=0[/itex] at the boundary of the volume. The number of modes in a frequency interval of width [itex]\mathrm{d} \omega[/itex] around [itex]\omega=c k[/itex] thus is
[tex]\mathrm{d} N=\mathrm{d}^3 \vec{k} 2 \frac{L^3}{\pi^3} = \mathrm{d} k k^2 4 \pi 2 \frac{L^3}{(2 \pi)^3}.[/tex]
The factor 2 comes from the two polarization states of the em. waves. In the last step we have written the volume elment in spherical coordinates and integrated out the angles. We have to multiply by [itex]1/8[/itex] because only the octand with positive wave numbers has to be taken. Written in terms of frequency we finally get
[tex]\mathrm{d} N=\mathrm{d} \omega 8 \pi \frac{L^3}{(2 \pi c)^3}.[/tex]
To get the energy spectrum we need the average energy in each mode at given temperature. According to classical physics each mode represents an oscillator, and its mean energy is thus [itex]k T[/itex] according to the equipartition law. This leads, however, to a wrong energy spectrum, particularly a divergent total energy in the electromagnetic field (Rayleigh-Jeans UV catastrophe), and only then your "intuitive" idea that the highest frequencies give the most energy in the radiation field.
Now, according to Planck's and Einstein's hypothesis on the quantization of radiation energy, each oscillator can take only discrete energy levels, [itex]E_n=n \hbar \omega[/itex] with [itex]n \in \mathbb{N}_0[/itex]. That means that the mean energy is
[tex]\frac{\sum_{n=0}^{\infty} n \hbar \omega \exp(-n \hbar \omega/(k T))}{\sum_{n=0}^{\infty} \exp(-n \hbar \omega/(k T))}=\frac{\hbar \omega}{\exp(\hbar \omega/(kT))-1}.[/tex]
The energy spectrum is thus given by
[tex]\mathrm{d} \epsilon=\frac{8 \pi \hbar \omega^3}{(2 \pi c)^3 [\exp(\hbar \omega/(kT))-1]} \mathrm{d} \omega,[/tex]
where [itex]\epsilon=E/V=E/L^3[/itex] denotes the energy density. This can be rewritten in terms of the wavelength, and finding the value for the maximum of the corresponding spectral function leads to Wien's displacement law: The wavelength of maximal emission fulfills the rule
[tex]\lambda_{\text{max}} T=\text{const}.[/tex]