All soft drinks contain water. When soft drink bottles are chilled in sub-zero temperatures, the water on account of its anomalous expansion expands. Thus, to provide space for expanding water, soft drink bottles are not completely filled as otherwise they will burst.
Soft drink bottles are filled leaving some space between the lid/cap and the liquid level.
The reason is that the soft drinks are cooled below room temperature. Sometimes they are kept in the hot Sun and weather. They are subject to a big temperature variation. Also, there are gases like CO2 mixed in the drink. So the gases come out of the liquid and expand due to heat. That creates high pressure.
Water expands when it is cooled to 4 deg. C. But the bottle (glass) contracts when it is cooled. So if there is no air gap, then volume of water (cool drink) will become more than the inside volume of the bottle. Then the bottle will break due to pressure from water expansion around 8 deg. to 4 deg.C.
When a bottle is opened, due to pressure difference, and temperature difference, the gases come out of drink in the form of bubbles. So cold drink overflows out.
Also, the soft drink bottles are capped tightly. When an opener is used to open it using some force upwards, the pulling force also moves the soft drink bottle upwards. So just after the lid comes off, the top part of the drink comes out due to the pull. So some drink spills on people who open or, it falls outside.
In order to prevent these problems, some gap is left open between the surface of the soft drink and the top of the bottle.