One essential step during the evolution of terrestrial gastropods (snails and slugs) from aquatic ancestors was the development of the ability to extract oxygen from the air. Gills that need to be surrounded with water to function efficiently are useless in air. Thus, in all terrestrial gastropods gills have disappeared and the inner surface of the mantle cavity has evolved into a lung. However, the lung surface must be kept wet at all times, because gas exchange always takes place across a film of water (even in human lungs).
In pulmonate gastropods, only a single hole, the pneumostome, connects the mantle cavity to the outside world. The large pneumostome of the slug Arion subfuscus is visible in the picture below. Unless the slug is abnormally sinistral, the pneumostome is always located on the right side of the mantle (the mantle is the flap of skin covering the back of the head).
If you watch a slug long enough, you will notice that its pneumostome rhythmically opens and closes, in other words, you will witness the slug breathing. The rate of breathing of a slug is probably determined by the metabolic rate and the state of hydration of the slug as well as the ambient temperature and humidity. The series of pictures below show the opening and closing of the pneumostome (arrow) of a Megapallifera during one complete cycle that took 23 seconds. Notice how the front of the mantle puffs up when the pneumostome is fully open. I am assuming that it is the air filling the mantle cavity that makes the latter to swell.