To understand why volcanoes erupt, you should first have a rough idea of the structure of our Earth. The Earth has three layers: the crust is the outmost layer with an average depth of about 22 miles; the mantle is the middle layer with a depth of almost 1,800 miles; the innermost part is the Earth core. The crust, the face of the Earth, is rock-hard, while the mantle is basically in a state of dense liquid, because the temperature there is so much higher than on the crust that virtually everything melts down. And the core is yet another story; there, the temperature and pressure are so extreme that they could be justifiably called unearthly, so much so that much of the melted iron and nickel (the two major components of the Earth core) get solidified again!
The volcanic lava all comes from the mantle, for the iron and nickel inside the core is just too deep to come up. And when the lava is still under the crust, it is called magma. Magma mainly consists of molten rock and can be lighter in some areas and denser in other. Such difference causes the magma to flow around with lighter magma always coming on top of the mantle.
Now, the Earth’s crust is not a complete piece; it is broken into 17 tectonic plates. These tectonic plates literally float above the liquid-like upper layer of the mantle. Because of such a structure of the Earth, the lighter magma in the mantle sometimes can break through some of the fissures between various tectonic plates, also called fault lines, and spout out. And for this reason, almost all volcanoes on the Earth are located where two or more tectonic plates are diverging or converging, simply because the crust is generally weak and cannot hold the rising magma underneath.
For a graphic display of how volcanoes form, check out the video below: