The pooling of magma in the crust below Mount Vesuvius can gradually build pressure on the rocks above. This inflow is partly due to the colliding African and Eurasian continental plates, which are ever-so-slowly closing the Mediterranean Sea. The rocks can be pushed upward until some part of the structure gives way (via an earthquake or other seismic shift), at which point hot rock and gases explode from the crater. This was the "Plinian" eruption that destroyed Pompeii in 79 AD. (Named for Pliny the Elder, who died during a rescue attempt, and Pliny the Younger who recorded an account of the disaster.)
Six years before the major eruption, the flat area near Vesuvius was the camp of the gladiator Spartacus and his army. A major earthquakes had occurred in 62 AD, indicating that the local geology was unstable.
The magma inside it was over presurized, under very high temperature, but was in an enclose, and it had to find a way to be free from the inbuilt stress, so it boiled and boiled until it eventually exploded, and erupting to the earths surface.