Honest answer: you have to be good. Rainbow Road gives you almost no room for error, and a single fall off the edge usually costs you the lead.
The practical approach is to learn the racing line through repetition, save your boosts for the long straights, and hold an item you can use defensively when someone closes in on you. Smooth steering beats frantic corrections, since the track punishes oversteering more than it punishes caution.