Hi. It is a cryoprotectant agent in order to protect the sensitive bacterial cells from ice crystal. With glycerol the formed ice crystals become smaller and the damage to competent cells is decreased.
We also add glycerol in preparing competent cells of E.coli DH5alpha. I think it serves both purposes to maintain the osmolarity and act as cryopreservant. Again, agents like glycerol, DMSO are added to freezing mixtures, glycerol stock preparation, competent cell preparation because they have higher freezing point (17.8- 19 degree C), which facilitates quick freezing. When kept in -80 or -20 degrees, the water molecules will freeze and cause the formation of ice crystals which may be harsh for the cells. Glycerol generally excludes water molecules and is expected to occupy the free space between the cells and hence protect cells from the damage caused by ice crystals. Also, as rightly mentioned, it would prevent any shrinkage of the cells due to the change in osmolarity upon freezing.