Minecraft kill all players except a certain player

EmeraldEye's answer works, but it removes all information on what team someone was if teams were used already. You could instead use tags, but there is an even easier way, in one command:

/execute at <player_name> as @a unless entity @s[distance=0] run kill @s

This is easy to write, but hard to understand. What this does is first shifting the execution position to the player you want to not kill, but still executing as whatever executes the command (a command block for example). Then it changes the execution context to be done by all players, without changing the position where it executes. It also splits up all further parts of the command, so that they run once per player. Then it checks if the selected player has distance 0 from the execution position (which is still the one player's position that you don't want to kill) and if they do not have distance 0, they get killed.
The advantage of checking for distance 0 and negating the selection is that it also selects people in other dimensions, unlike something like if entity @s[distance=0.001..] would do.

Keep in mind that this command will not kill players that are on the exact same position as the player you don't want to kill. But that can only happen in rare situations like respawning, dismounting a minecart at a fixed position, teleporting, … and then not moving before the other player does the same.