Upshifting can also be useful for saving fuel. If the next higher gear has enough power for the current situation, you can operate at lower revs by shifting to it.
Downshifting is trickier. Shifting to a lower gear under braking can aid the brakes in slowing the car. However, it can also upset the balance and cause the tires on the driven wheels to lose grip. It would make sense to shift to a lower gear when that gear would give more engine power. In practice, that strategy often leads to loss of control. Shifting down one gear when shifting down two gears would give more power, and never shifting to first gear, appears to be reliable.
The current algorithm could be improved upon. A real driver would blip the throttle when downshifting to ease the transition to a lower gear. This has not been implemented for the robot driver.
As anyone who has driven a car with an automatic transmission knows, trying to pick the best gear based on the current conditions can lead to indecisive shifting. A better algorithm might use knowledge of the track to anticipate the need to shift.
Currently the robots use more fuel than they need to. A better shifting algorithm could also improve fuel consumption.