A Messy Kitchen Moment
Almost everyone who cooks pasta has experienced it. You put a pot of water on to boil, drop in the pasta, turn away for a moment, and suddenly the water is frothing up and spilling over the sides of the pot onto the stove. Plain water on its own rarely does this. It can boil vigorously for a long time without overflowing. So something about adding pasta changes the situation, and that something is starch.
What Boiling Normally Looks Like
When water boils, it turns into steam, and bubbles of steam rise up through the liquid and burst at the surface. In plain water, these bubbles pop quickly and easily as soon as they reach the top. The steam escapes into the air, and the water level stays roughly the same. The bubbles simply cannot hold together long enough to pile up. This is why a pot of pure water can boil away steadily without making a mess.
The Role of Starch
Pasta is made mostly from wheat, and wheat is rich in starch. When pasta cooks in hot water, its starch granules absorb water, swell up, and release starch molecules into the surrounding liquid. This starch changes the behavior of the water's surface. The bubbles of steam rising through starchy water become coated and more elastic, so instead of bursting instantly, they hold together. The result is a layer of foam building up on top of the water.
How the Overflow Happens
This foam layer is the real cause of the boil-over. The stable bubbles do not pop easily, so they trap the steam trying to escape from below. As more steam is produced, the foam expands and is pushed upward, like a lid being lifted by pressure. Eventually the rising foam climbs over the rim of the pot and spills out. There are simple ways to prevent this, such as using a larger pot, stirring the pasta, lowering the heat, or not covering the pot, all of which keep the foam under control.
Source
This article was written using information from Wikipedia.