In the fluff there is is 2 purposes
1) heat ventilation, as suggested tyranids run "hot". There are some of the older fluff that suggests they effectively steam. Note this is actually quite energy wasteful as heat is the most difficult form of energy to trap and reconvert, so goes against nids as they super efficient hunter so unsure if its still canon.
2) spore dispersion, Larger tyranids excrete spores in the atmosphere and surrounding air to increase the rate of tyranification of the prey world, generally poisoning its defenders in the process. Some creatures are designed exclusively for this but all larger creatures have some extent of spore mechanism
Tyranids don't get battlefield creatures to vacuum!
Oh and returning to the if they don't fire they explode, yet thats true, its expressly mentioned in the codex for one of the guns, the main gun creature can be eaten by the ammo creature if the ammo is not expelled at regular intervals, think it might be the fleshborer hive but can't recall off the top of my head