And there's generally a combination of principles involved, and different speedrunners and communities will prioritise different ones:
Fairness: generally speaking the competition wants to be fair. Part of this is just having a consistent set of enforced rules, but it also comes down to decisions about timing and allowing or disallowing certain tricks: if how fast part of a game is depends on how fast your hardware is, for example (whether by a trick working or simply lag), then most communities will try to eliminate this effect by banning hardware-dependent tricks or adjusting timing rules to remove loading times.
Competition: At the end of the day speedrunning is a competition around a game, so there's a general resistance to modifying the game itself, or e.g. use of external tools to assist the player beyond what was intended by the developer. But that will sometimes be compromised if there's some aspect of the game which badly affects other goals.
Fun: At the end of the day, speedruns are something that should be fun and rewarding to play and watch. So if the optimal run of a game becomes unfun to play or watch, then generally something will be done about it, whether by banning the trick which is unfun or by allowing something which alleviates the pain point (sometimes this even verges into health concerns: some pokemon games, for example, have very long runs with a huge amount of button-mashing to get through dialogue quickly, and RSI is a very real concern which means that turbo controllers which automate that are sometimes allowed). This can go as far as patching the game to remove particularly unfun or RNG-heavy parts, though it's rare.
And of course you can have different categories which will focus on different aspects of this, especially as different runners and watchers will have different ideas on what is fun: apart from what counts as 'beating the game' (any%, 100%, 'true ending', whatever), there's different levels of what other compromises are allowed. And it can get pretty contentious: from hardcore 'play the game as intended' purists to arbitrary-code-execution TASers, everyone has a different idea about what they enjoy in the competition, and different games can have strengths in each area of focus.