All engines have a redline, which is the maximum rpm value they can accommodate. Beyond the redline, the engine will explode. Since you would probably prefer that your engine not explode, you have to keep an eye on the redline, especially in a manual-transmission car. When you shift gears in a manual transmission car, you're making sure that the engine stays below the redline. To shift gears, you move the gear shift and hold down the clutch. The shift lever controls rods that control forks that engage the gears. The clutch is what connects the engine to the transmission. The transmission's input shaft has to spin at the same rpm as the engine. In a five-speed transmission, there are five different gear ratios that relate to the input shaft in order to yield a different rpm value for the output shaft.
Despite the redline guideline, there is still only a narrow rpm range in which your engine works its best in terms of torque and horsepower. Shifting gears allows you to stay close to your engine's maximum performance range when possible. The problem with this narrow performance range is that it only works at a single gear ratio, which means your car only performs its best at one specific speed.
Continuously variable transmissions, or CVTs, were designed in order to switch gear ratios so that your engine has a chance to stay near its optimal performance range at different speeds. For a while, continuously variable transmissions weren't nearly as efficient or cost-effect as regular four and five-speed transmissions, so they didn't get much widespread use. However, improvements to the technology have allowed CVTs to become more popular. Still, the bottom line in any type of transmission is to avoid the redline in order to ensure the wellbeing of your engine.