RC electronics are designed to run on a certain range of voltages. Like some motors can handle 2-4s. Some might only handle up to 3s. The same goes for your ESC. And the motor and ESC might handle different cell counts. Like the ESC might only handle up to 3s, while the motor can handle 4s. So 3s would be your limiting factor. You can't just throw whatever you want at them.
Vehicle weight and drivetrain has a lot to do with it as well. Take Castle electronics for example. They tell you in the specs how many cells you can run, what vehicle type they are designed for, and they list a maximum weight. Running a vehicle with more weight than the electronics are rated for will cause the electronics to overheat and burn up.
So you have to first pick electronics designed for your RC, then the rest comes down to gearing. As long as you aren't running your electronics too hot, you can increase the tooth count on the pinion and get more top end, but you will lose acceleration, so it's a give and take that you tune to your liking. You want to stay below °160F on your ESC and motor temps, no matter what RC you run. Anything above that can cause failures. So if you up the pinion size, and your temps push °160F, you need to back down a tooth.