Cubes are the natural shape of sugar crystals. The reason why this happens is because it's the efficient way to pack the atoms of sugar at the temperature and pressure that we have them.