How serious is the oxygen sensor to the maintainance of the vehicle on 2006 Hyundai Santa Fe

Concerned that check engine light comes on every so often, was told it could be the oxygen sensor, or not consistently using premium gas, or the gas cap not closed tightly.

1 answer
It is necessary.