Bees attach comb to the sides of a top bar hive to brace the comb, holding this amazing engineering feat in place.
The side walls of a top bar hive are sloped inward towards the bottom so the bees will build less comb attachment to the walls of the hive. This is the reason for the angle of the sides of the hive. If the hive were a square box the bees might attach the comb they draw out along the entire side of the hive. This would make it very difficult to harvest the honeycomb from the hive.
The honeycomb is quite heavy when the whole comb is filled with honey. This is one reason the bees attach this heavy comb to the sides of the hive.