So your new bike has a 50-34 chainset and a 12-28 cassette. What does that mean?
The first pedal cycles had the cranks fixed directly to the front wheel. The only way to change gear, and thus travel a different distance for each revolution of the cranks, was to change the size of the wheel. A bigger wheel went further, which is how penny-farthings arose. Chain-driven bikes revised that: wheel size was still a factor, but you could travel more or less distance per crank revolution by altering the size of the chainring fixed to the cranks and/or the sprocket fixed to the rear wheel. Once chosen, the gear ratio was still fixed. To change it, you'd have to remove the rear wheel and fit a different sprocket, something fixed-wheel riders do to this day. Variable gears give us something we take for granted: the ability to change gear as we ride along.
Derailleur gearing is the most common kind of variable gearing in the UK. Changing gear means derailing the chain from one chainring or sprocket to another - hence the French term derailleur. Having multiple gears doesn't make a bike faster as such; it makes cycling easier. You can keep pedalling at a comfortable cadence while the rear wheel revolves slower or faster. It's a huge help when it's hilly or windy, or if you're carrying a load.
27 gears is 9-speed?
Derailleur-geared bikes have one, two or three chainrings and from six to 11 sprockets on the rear hub's cassette. When magazines and websites talk about a bike's 'speed', it's a reference to the number of sprockets. A bike with three chainrings and nine sprockets is 9-speed, even though it has 27 theoretical ratios. The higher the sprocket count, the more expensive, smoother shifting, and lighter weight the gears. There are big differences between a bike with 3x6 gearing and a bike with 2x9, even though both have 18 theoretical ratios.
Most rear derailleurs use indexed shifting. Each click of the shift lever moves the derailleur sideways a set amount: the distance from one sprocket to the next. Since 9- and 10-speed squeeze more sprockets into the same space as 8-speed, these gaps are smaller in 9- and 10 speed than in 8-speed. That's why you can't ordinarily use a 9-speed shifter and an 8-speed derailleur. The shifter would move the derailleur the wrong amount every time, so the chain would keep slipping in and out of gear.
Gear ratios & range
Derailleur gear shifting visibly changes the gear ratio, which is the ratio between the size of the chainring and the size of the sprocket. The bigger the chainring-to-sprocket ratio, the bigger the gear and the faster you'll go at a given cadence. The smaller the chainring-to-sprocket ratio, the smaller the gear and the easier it will be to pedal uphill.
Note that a bike's gear range, the difference between top gear and bottom gear, is not directly determined the number of gears. An 11-34 8-speed cassette has a greater range than a 9-speed 12-25 cassette. The 9-speed cassette has smaller steps between gears, which is primarily useful for racing.
The range of gears you need will depend on the terrain and on how you like to pedal. If it's flat where you live, or you're athletic, one gear might be enough. Probably you'll want eight or more, with the lowest gear small enough to get you up the hardest hill you'll encounter. Don't worry about the top gear. If you're pedalling it as fast as you can and still feel you could go faster, stop pedalling: freewheel!
A bike's top gear is its biggest chainring and smallest sprocket combination, while its bottom gear is its smallest chainring and largest sprocket. To compare gear ranges between bikes, you need to do some maths. Let's say bike A has 50-34 chainrings and a 12-28 cassette, and bike B has 26-36-48 chainrings and an 11-34 cassette. Here are three different ways to measure the gears.
1. Ratio of chainring size to sprocket size
Divide the chainring size, in number of teeth, by the sprocket size, again in number of teeth. Note that this only works for bikes with comparable wheel sizes. Bike A has a bottom of 34/28, a ratio of 1.2. The rear wheel will turn 1.2 times for each crank revolution in bottom gear. Bike A's top gear is 50/12 or 4.2 (revolutions). That's a range of 1.2-4.2. For bike B, the range is 0.8-4.4. Bike B has a lower bottom gear and a higher top gear.
2. Gear inches
This takes into account the size of the wheel. It describes the effective diameter of the wheel, telling you how big a penny-farthing wheel would be if it had a matching gear! Divide the chainring size by the sprocket size, as above, and then multiply it by the bike's wheel diameter. (You can either measure this or use nominal sizes: 26in for a 26in wheel, 27in for a 700C wheel, etc.) Assuming bike A has 27in wheels and bike B has 26in wheels, bike A has gears ranging from (34/28*27) to (50/12*27) or 33-113in. Bike B has gears ranging from 20-113in. So top gear is actually the same, due to bike B's smaller wheels.
3. Gear development
This tells you how far the bike travels in a given gear for each revolution of the cranks. In other words, it's the effective circumference of the rear wheel in each gear. To find this, multiply gear inches by pi (3.14) and, by convention, convert to metric. Gear development for bike A is 2.63-9.01 metres and for bike B it's 1.59-9.01 metres.
If you calculate every chainring and sprocket combination on your bike, you'll discover overlapping gear ratios if the bike has multiple chainrings. For example, 34/17 is exactly the same gear as 50/25. A bike with 18 potential ratios might have only a dozen usefully different ratios.
If you don't want to do the maths, meanwhile, just eyeball the chainring and sprocket sizes. If it's hilly where you ride, look for a bottom gear of 1:1 or less – and the lower the better.