The material you are purchasing is based on area (so many dollars per square foot) so you need an equation for area, i.e., surface area.
We'll assume there is no top on the box. Also, notice that the bottom is a square (so L x L)
The surface area of the bottom of the box is one side times the other (L•L)
The surface area of the two ends is width x height (L•H)
The surface area of the two sides is length x height (L•H)
So the total surface area is L•L + 4(L•H)
You also know that you are limited to a volume of 4 cubic feet so L•L•H = 4 or H = 4/L2
So SA = L•L + 4L•(4/L2)
And since the cost for the bottom is $5 and the cost for the sides is $2 we can say:
Cost = 5•L•L + 2•4L•(4/L2)
Simplifying:
C(L) = 5L2 + 32/L
C(L) = 5L2 + 32L-1
To minimize cost, take the derivative and set it equal to zero:
C'(L) = 10L + -32L-2
0 = 10L + -32L-2
0 = 10L + -32/L2
32/L2 = 10L
32 = 10L3
32/10 = L3
16/5 = L3
L = cuberoot(16/5) = 1.474 ft