If your water heater's pilot light won't stay lit, fix it immediately.
Several problems can shut off the pilot, such as a failed gas supply, lack of combustion air due to a clogged vent or a vent draft that blows out the pilot. A missing, crooked or blocked vent draft hood can cause a vent draft. Also, if the vent pipe cap on the top of the vent pipe on the roof is blocked or missing, wind can go down the pipe and blow the pilot out.
Another common problem causing the pilot to go out or not stay lit is a failed thermocouple (pilot generator). The thermocouple in your water heater keeps the pilot lit by sending a low current electrical signal to keep the gas valve open. If the thermocouple fails, it doesn't send the signal to the gas valve and the gas valve shuts off, extinguishing the pilot.
When lighting the pilot, you press and hold the pilot button to supply gas to the pilot until the pilot heats up enough to generate the signal to keep the gas valve open on its own. If the pilot light goes out when you release the button, you'll likely need to replace the thermocouple because it isn't sending the signal to the gas valve to keep the gas valve open.