The energy levels for a particle in a box are $E_n = \frac{\hbar^2 \pi^2 |n|^2}{2 m L^2}$ where $n \in \mathbb N^3$. So what we're doing is
\begin{align*}
Z &= \prod_{i=1}^N\left[\sum_{n^{(i)} \in \mathbb N^3}\right] \exp\left(-\beta \sum_{j=1}^N E_{n^{(j)}} \right)\\
&\approx \prod_{i=1}^N\left[ \int_{\mathbb R_{>0}^3} d^3n^{(i)}\right] \exp\left(-\beta \sum_{j=1}^N E_{n^{(j)}} \right)\\
&= \prod_{i=1}^N\left[ \frac{L^3}{8\pi^3}\int_{\mathbb R^3} d^3k^{(i)}\right] \exp\left(-\beta \sum_{j=1}^N \frac{\hbar^2 |k^{(j)}|^2}{2m} \right)\\
&= \prod_{i=1}^N\left[\frac{1}{8\pi^3}\int d^3 x^{(i)}d^3k^{(i)} \right] \exp\left(-\beta \sum_{j=1}^N \frac{\hbar^2 |k^{(j)}|^2}{2m} \right)\\
&= \prod_{i=1}^N\left[ \frac{1}{8\hbar^3 \pi^3}\int d^3 x^{(i)}d^3p^{(i)} \right] \exp\left(-\beta \sum_{j=1}^N \frac{|p^{(j)}|^2}{2m} \right)\\
&= \prod_{i=1}^N\left[\frac{1}{h^3}\int d^3 x^{(i)}d^3p^{(i)} \right] \exp\left(-\beta \sum_{j=1}^N \frac{|p^{(j)}|^2}{2m} \right)\\
&= \frac{1}{h^{3N}} \prod_{i=1}^N\left[\int d^3 x^{(i)}d^3p^{(i)}\right] \exp\left(-\beta \sum_{j=1}^N \frac{|p^{(j)}|^2}{2m} \right).
\end{align*}
Note that the factor of $8$ comes from the following fact. When we integrate over $n$, we are integrating over all $n \in \mathbb R_{> 0}^3$. When we integrate over $k$, we are integrating over all $k \in \mathbb R^3$. Thus we must divide by $8$ to represent the fact that we are only interested in the all-positive octant.
In the second line, we are simply saying that $N$ is large enough that the sum can be approximated by the integral. In the third line, we change variables to $k_x = \pi n_x / L$, and similar for $y$ and $z$. In the fourth line, we use that $L^3$ is the volume of the box. In the fifth line, we change variables from $k_x \to p_x = \hbar k_x$, and similarly for $y,z$.
The $1/N!$ comes from the fact that we say particles are indistinguishable, but the way we've done the integral suggests that they are distinguishable (i.e. we've kept track of the $i^{\rm th}$ particle throughout). Since particles are indistinguishable, we divide by the total number of permutations of the $N$ particles, $N!$, to get the correct result.