Boltzmann postulated the existence of a relationship between the total entropy of a thermodynamic system and the total number of microstates $(\Omega)$ in which the system can be found.

$$S=kln\Omega \label{ec17}$$

Since $\Omega=\sum_{j}W_{j}\approx{W_{max}}$, where $W_{max}$ represents the most probable macrostate, which for simplicity we will represent by $W$. Thus, the Boltzmann Postulate leaves us with:

$$S=klnW \label{ec18}$$

where $k$ is the Boltzmann constant $k=1.38\cdot10^{-27}J /K$ and $W$ is the macrostate with the largest number of microstates.

For a system with degeneracy, the number of microstates of the most probable macrostate is given by:

$$lnW=NlnN+\sum_{i}N_{ i}lng_{i}-\sum_{i}N_{i}lnN_{i} \label{ec19}$$

Substituting (~\ref{ec19})into (~\ref{ec18})

$$S=kNlnN+k\sum_{i}N_{i}lng_{i}-k\sum_{i}N_{i}lnN_{i} \label{ec20}$$

Taking natural logarithms in Boltzmann's Law (~\ref{ec16})

$$lnN_{i}=lnN-lnq+lng_{i}-\beta\epsilon_{i} \label{ec21}$$

Substituting into (~\ref{ec20})

$$S=kNlnN+k\sum_{i}N_{i}lng_{i}-k\sum_{i}\left(N_{i}lnN-N_{i }lnq+N_{i}lng_{i}-N_{i}\beta\epsilon_{i}\right) \label{ec22}$$

Splitting the sum:

$$S=kNlnN+k \sum_{i}N_{i}lng_{i}-kNlnN+kNlnq+k\sum_{i}N_{i}lng_{i}+k\ beta\sum_{i}N_{i}\epsilon_{i} \label{ec23}$$

Simplifying gives an equation for entropy

$$S=kNlnq+k\beta{E} \label {ec24}$$

Differentiating S:

$$dS=kN\frac{dq}{q}+kEd\beta+k\beta{dE} \label{ec25}$$

As $q=\sum_{i}e^{-\beta{\epsilon_{i}}}$ deriving:

$$dq=\sum_{i}{-\beta{e^{-\beta{\epsilon_ {i}}}d\epsilon_{i}}}-\sum_{i}\epsilon_{i}e^{-\beta{\epsilon_{i}}}d\beta \label{ec26}$$

Substituting (~\ref{ec26}) into (~\ref{ec25}):

$$dS=-kN\frac{\beta\sum_{i}{e^{-\beta{\epsilon_{ i}}}{d\epsilon_{i}}}}{q}-kN\frac{d\beta\sum_{i}\epsilon_{i}e^{-\beta{\epsilon_{i}}}} {q}+kEd\beta+k\beta\sum_{i}\epsilon_{i}dN_{i}+k\beta\sum_{i}N_{i}d\epsilon_{i} \label{ec27}$$

In the equation (~\ref{ec27}) the first and last terms are equal, as are the second and third terms. Simplifying:

$$dS=k\beta\sum_{i}\epsilon_{i}dN_{i} \label{ec28}$$

From the point of view of classical thermodynamics $dE=TdS- PdV$. In statistical mechanics $dE=\sum_{i}\epsilon_{i}dN_{i}+\sum_{i}N_{i}d\epsilon_{i}$. Equating the first terms of both equations:

$$TdS=\sum_{i}\epsilon_{i}dN_{i} \label{ec29}$$

Comparing the equation (~\ref{ec28}) and (~\ref{ec29}), it follows that $k\beta=\frac{1}{T}$, solving for $\beta$

$$\beta=\frac{1}{kT} \label{ec30}$$