It's a safety device - it sits in the flame and provides heat information to the oven's controls. No heat signal from the thermocouple = no gas flow.
If the gas failed while the oven was on but you were somewhere else - having a bath - in the garden - down the shops the flame would go out. If the gas pressure suddenly came back, unburnt gas could flood the house and a spark could cause an explosion.
http://www.suremarine.com/images/stove-repair/safety-pilot.jpg
Peccavi
November 2009