How do time zones work and why do we have them?

How do time zones work and why do we have them?