It burns off the gas. It is largely illegal worldwide today, except during testing; before gas lines are laid; or when the gas can not be safely got rid of any other way.
It's known as a flare stack, and is used to burn off any gas that is vented when a shut down or emergency occurs, to avoid the release of unburnt gas.
A small supply of gas is piped to the flare tip to act as a pilot light and keep it burning.
( I'm typing this on an off-shore platform right now...)