The method the wine merchant had used to measure the volume of the barrel that had so shocked Kepler was to insert a stick through the tap hole (at \(S\)) in the diagram below) to the opposite edge of the lid of the barrel (at \(D\)).
Figure 5. Austrian merchants set the price of a full wine barrel according to the length \(SD\). (Underlying image from p. 98 of Kepler's 1615 Nova stereometria used by permission of the Carnegie Mellon University Libraries)
According to Toeplitz (pp. 8283):
Then he read off the length \(SD = d\) and set the price accordingly. This outraged Kepler who saw that a narrow, high barrel might have the same \(SD\) as a wide one and would indicate the same wine price, though its volume would be ever so much smaller.
Figure 6. Two cylinders with the same measurement \(SD\) may have very different volumes. (After an image from Toeplitz, p. 82)
In consequence, Kepler tried to determine the best proportions for a wine barrel in order to maximize the volume. This led him to consider a number of problems on maxima and minima, which proved to be a very interesting contribution to the development of the differential calculus. For example, Kepler was able to establish that the cube is the largest parallelepiped that can be inscribed in a sphere (Baron, p. 115).
Of course, the problem of finding maxima and minima was not new. For example, Euclid had proven that, among all rectangles of equal perimeter, the square has the largest area (Toeplitz, 80). Pappus of Alexandria around 300 CE showed that, for equilateral and equiangular plane figures having an equal perimeter, the figure with the greater number of angles has the greater area and the largest such area is that of the circle with the same perimeter.
The Sagacity of Circles: A History of the Isoperimetric Problem This Convergence article by Jennifer Wiegert gives a summary of the history of the problem of finding the region of greatest area bounded by a given perimeter. 

Thinking Outside the Box  or Maybe Just About the Box In an article in Loci by David Meel and Thomas Hern, the authors study a more realistic and therefore complex box problem than the traditional one and show how it can be used to investigate optimization. 