This phenomenon is due to the interaction of light with ice crystals in the atmosphere, so it falls into the class of halos in atmospheric optics. Light pillars are typically strongest and highest with artificial light sources. However, slightly different conditions can cause pillars with the sun and moon as well.
Light pillars are caused by ice crystals reflecting relatively strong light sources to the viewer’s eye from plate-shaped ice crystals. So there isn’t actually a pillar of light shining over the light source like with light beams, but the viewer sees the light reflected off the flat surface of the ice crystals between the observer and the light source creating a virtual image, a kind of an illusion of a beam. A pillar will look different (or not exist) depending on the position of the observer due to the amount of and altitude of the ice crystals. This can be very apparent when seeing light pillars while driving as they may change in intensity over different altitudes rapidly while moving.
Light pillars are most commonly seen when it is very cold and very calm (no wind), so that the majority of plate-like ice crystals are oriented with the faces parallel to the ground. If it’s too windy, the plates are much too randomly facing to cause this effect.