We may all be familiar with the part of the cabin safety briefing where they say that, in the event of a reduction in cabin pressure, oxygen masks will drop from a compartment above our heads, yadda yadda, the bag may not inflate. What is the purpose of the bag?
Oxygen in passenger masks is either generated by oxygen generator or released from pressurized container via reduction valve. In either case it is released at fixed rate. But human breath is discontinous. So the bag acts as a buffer. You inhale the oxygen accumulated in it and then it slowly refills while you are exhaling.
In addition to what our friend Jan Hudec mentioned:
The mask may also have a concentrator or re-breather bag that may or may not inflate depending on the cabin altitude, which has (in some instances) made passengers nervous the mask was not providing adequate oxygen, causing some to remove them, who thereby suffered hypoxia.
The partial rebreather is the most common. With these, there's an external plastic bag that inflates each time you exhale. The purpose of the bag is to store any unused oxygen, so that it can be inhaled with the next breath.
I can't actually track down the purpose of the bag; however, the FAA Oxygen Equipment guide states that it is not for the purpose of mixing exhaled air with pure oxygen:
The phase-sequential continuous-flow mask looks similar to a general aviation re-breather. However, both masks function differently, and the phase sequential mask allows the user to go to higher altitudes. This mask uses a series of one-way ports that allow a mixture of 100% oxygen and cabin air into the mask. Exhalation is vented to the atmosphere; as a result, the bag does not inflate. [emphasis mine] This mask can be safely used at emergency altitudes up to 40,000 feet.
Because of the construction, the bag seems to act as a buffer, as Jan Hudec states in his answer.