The hive works as a shelter, as a nest and a place to store the honey. The whole place is designed to maximize space efficiency using the fewer materials possible.
Bees use around 3 kilos of honey in order to produce half of the wax. As they need the honey to thrive, they have to come up with a design that allows storing the maximum amount of honey using the less possible wax. The shape which has the most space to store the honey using the minimum material is the circle.
However, there is a problem with this design: between the circles small gaps are created, which means wasted space. Why not using triangles or squares, then? They can fit perfectly without creating any dead space.
We have to understand that the space-efficient comb from the bees we know today is the result from trial and error over a long period of evolutionary history. Thus, with time, they came up with a better design, the hexagon. Given that it resembles more of a circle than a triangle or a square, the amount of wax used to create a cell is reduced. Hexagons also have an added benefit: they are great at structural load distribution, which is important to keep in mind if we consider that the whole hive can get as heavy as 4 kilograms!