Joseph Stefan induced this relation from some experimental data (1884). His student, Ludwig Boltzmann, derived the 4th power of absolute temperature T relationship from radiation thermodynamics and electromagnetic waves. That is why his name is attached to Stefan's discovery.
I can't follow all of this, but here is a bare outline of how it goes.
-----------
TdS = dU + pdV
{combined 1st and 2nd laws of thermodynamics in differentials, T = absolute thermodynamic temperature of radiation, S = entropy for a reversible process, U = internal energy of radiation, p = radiation pressure against container walls, V = volume of radiation container, thermal equilibrium between radiation and container walls, treat radiation as if it is a gas}
T(S,V) = (U,V) + p
{(S,V) means partial derivative of S wrt V, (U,V) means partial derivative of U wrt V, and so on, of course (V,V)=1}
--
H = U + pV
{H is enthalpy function}
dH = dU + (dp)V + pdV = (dU + pdV) + (dp)V = TdS + V(dp)
{substitute from combined thermodynamics laws}
But,
dH = (H,S)dS + (H,p)dp
{partial derivatives of H}
(H,S) = T and (H,p) = V
{substitutions from prior result for dH, dH is an exact differential}
((H,S),p) = ((H,p),S)
{partial second derivative}
(T,p) = (V,S)
{substitutions from preceding equations}
(S,V) = (p,T)
(inverse partial derivatives}
T(p,T) = (U,V) + p
{substitution into the 2nd equation from the top}
--
p = ë/3
{ë = energy density of radiation, *some detailed electromagnetic derivation of waves reflecting off container walls producing pressure, the pressure is isotropic}
U = ëV
(internal energy of radiation is energy density times interior volume of container}
(p,T) = (ë,T)/3
(U,V) = ë
{partial derivatives for preceding two equations}
T(ë,T)/3 = ë + ë/3 = 4ë/3
{substitutions into preceding differential equation result}
(ë,T)/ë = 4/T
{separate the variables for purpose of integration}
(ln ë,T) = 4/T = 4(ln T,T)
ln ë = 4(ln T) + constant = ln(T4) + constant
ë = (econstant)T4
{e is base of natural logarithm function}
{DONE}
So, radiation density is proportional to fourth power of absolute thermodynamic temperature of radiation under these conditions.
-----------
I got this from looking at Longair,Theoretical Concepts in Physics,Cambridge(1984),section 8.2.3 and earlier sections as cited