I have two solutions to this problem.
Intuitive solution
Intuitively, it seems to me that the greatest distance across the box would be the diagonal, which can be calculated according to the Pythagorean theorem:
$$h = \sqrt {l^2 + w^2}$$
If you'd like a more rigorous solution, read on.
Calculus solution
Treat this as an optimization problem.
For a box of width $w$ and length $l$ (because depth doesn't really matter in this problem), the height when the box is upright, assuming $l > w$, i
$$h=l$$
If the box is rotated at an angle $\theta$ to the horizontal, then we have two components of the height: the height $h_1$ of the short side, $w$, and the height $h_2$ of the long side, $l$. Using polar coordinates, we have
$$h_1 = w sin \theta\\
h_2 = l cos \theta$$
Thus, the total height is
$$h = h_1 + h_2 = w sin\theta + l cos \theta$$
This intuitively makes sense: for small $\theta$ (close to upright), $w sin \theta \approx 0$, and $l cos \theta \approx l$, so $h \approx l$ (and similarly for large $\theta$).
The maximum height required means we need to maximize $h$. Take the derivative:
$$\frac {dh}{d\theta} = \frac d{d\theta} (w sin \theta + l cos \theta) = w cos \theta - l sin \theta$$
When the derivative is zero, we may be at either an extremum or a point of inflection. We need to find all of these on the interval $(0, \frac \pi 2)$ (because we don't case about anything outside of a standard 90° rotation).
So, we have
$$0 = \frac {dh}{d\theta} = w cos \theta - l sin \theta\\
w cos \theta = l sin \theta$$
And, because of our interval $(0, \frac \pi 2)$, we can guarantee that $cos \theta \neq 0$, so
$$\frac w l = \frac {sin \theta} {cos \theta} = tan \theta\\
\theta = atan \left (\frac l w \right )$$
Now that we know that the maximum is at $\theta = atan \left (\frac l w \right)$. We can plug that back into our polar coordinate equation to get
$$h = w sin \theta + l cos \theta\\
h = w sin \left ( atan \left (\frac l w \right ) \right ) + l cos \left ( atan \left (\frac l w \right ) \right )$$
That's my 2¢.