The processes forming obsidian are not well understood because an active obsidian-forming eruption has never been recorded by humans. However, we can make many inferences from the composition of the rock and settings in which it is found.
Obsidian is more than 70% weight percent SiO2 (i.e. rhyolitic), but has less than 0.5 weight percent H2O, and almost 0% gas bubbles (vescicles). This is very unusual because high-silica magma typically also contains a high volatile content. That means they can contain up to 8% H2O, CO2 and other species that easily become gasses. Because the rock is "missing" water and has no gas bubbles, we know that the gas escaped the rock while it was molten. This process normally takes quite a bit of time, so you might think obsidian cools slowly so that all the volatiles could diffuse out of the rock without forming bubbles.
If you thought that, you would be wrong.
Here's why: The SiO2 is almost 100% in glass form (amorphous) rather than in crystals. Any crystals that do exist are microscopic. This is strong evidence saying the rock cooled quickly, because if it cooled slowly the SiO2 would have had time to organize itself into crystals as it cooled. Further supporting the idea that it cools quickly is the fact that it is not observed underground (as an intrusive rock, which would have cooled slowly.)
One way to explain this "low volatile, glassy texture" paradox is to say the lava was kept hot for long enough time that the gasses were able to escape, and then cooled very suddenly. Another possibility is that the parental magma was extremely dry (low-volatile) to begin with for some reason.
Modern humans have never seen obsidian erupt primarily because rhyolitic eruptions are rare. However, obsidian is rare even among rhyolitic eruptions, presumably because lots of open-system degassing followed by rapid cooling is an unusual phenomenon. There are many places in the world that seem to habitually produce obsidian and have produced enormous volumes of it. The Valles Caldera in New Mexico is a particularly good example, with a huge lava flow and several lava domes all constructed from obsidian. Similar lava domes called the Inyo Domes near Mono Lake, CA have been fundamental to the understanding of the behavior of stable isotopes in magmatic systems and are probably the most well-known outcrops of obsidian among geologists.