How Time Zones Began
Time zones exist because of trains. Once a train could pass through several towns in a day, every town keeping its own sun time turned timetables into a mess. Railways agreed on shared times first, governments caught up later, and in 1884 an international conference picked Greenwich as the world's starting line.
Life on local sun time
Each town set its clocks by the sun, so noon was simply whenever the sun stood highest. Two towns a few dozen miles apart could be several minutes out from each other, and nobody minded, because the fastest way to get between them was a horse. You just changed your watch when you arrived.
Then the railways arrived
Try reading a timetable with fifty stops on fifty local clocks, or running two trains safely on one track with it. British railway companies switched to a single "railway time" based on London in the 1840s. North America, being far wider, had its railroads bring in standard time zones on 18 November 1883, and the towns slowly followed.
How Greenwich became zero
In 1884 delegates from many countries met in Washington, D.C. for the International Meridian Conference, where they agreed that the meridian through the Royal Observatory at Greenwich would be the world's prime meridian, the zero point for both longitude and time. That's why GMT and UTC still point back to one spot in London. The modern side of that story is in what UTC and GMT are.
Nobody adopted it all at once
It took decades, and countries made their own choices along the way. Some went for 30 or 45-minute offsets. Some very wide countries picked a single zone, India among them (why India has one time zone), while the US and Russia went with several. Daylight saving came later still, and its rules keep changing; how daylight saving time works covers that part.
Why the borders wiggle
On paper each zone is 15 degrees wide. In real life nobody wants half a town on one time and half on another, so the borders bend around countries, states and islands. Some places go further and pick a zone that doesn't match their position at all, usually to stay in step with a capital or a big trading partner.
Why this history still matters
Almost everything about time zones is a human decision, which explains why they're so uneven and why they keep changing. So if you need an exact conversion, use something built on an up-to-date time zone database, like the Time Zone Converter, or look the place up in the list of countries.