Nepo knew the rules but didn't know how to implement the castling given the rook was occupying the square that the king was supposed to be in.
According to this article, that is simply not what happened (according to the arbiters, after Nepo appealed the initial ruling).
What happened was the following:
- Nepo wants to castle kingside, so the king needs to go to g1.
- The rook randomly started on g1 (and is still there).
- Nepo moved the rook out of the way in order to move the king to g1.
- So did not object to this maneuver, but an arbiter spotted it and told Nepo to move the rook.
- He did so, and then appealed the decision, saying it was impossible to move the king first.
- The arbiters reviewed the video and determined that he had clearly intended to castle, so the ruling was erroneous. They then ordered the game replayed.
The FIDE Chess960 rules, under "Guidelines II," state that the "game is played in the same way as regular chess" after the pieces have been set up, and characterize the Chess960 castling rules as an "interpretation" of the orthodox chess rules. So we can look at the orthodox chess rules to see how the arbiters justified their ruling.
This is what the orthodox rules have to say about touch-move and castling:
4.4 If a player having the move:
4.4.1 touches his/her king and a rook he/she must castle on that side if it is legal to do so
4.4.2 deliberately touches a rook and then his/her king he/she is not allowed to castle on that side on that move and the situation shall be governed by Article 4.3.1 [i.e. the player must move the rook if possible].
4.4.3 intending to castle, touches the king and then a rook, but castling with this rook is illegal, the player must make another legal move with his/her king (which may include castling with the other rook). If the king has no legal move, the player is free to make any legal move.
If Nepo touched the king first, or if he touched the king and rook at approximately the same time, then this scenario would fall under 4.4.1, and in fact Nepo would be required to castle. 4.4.2 only applies if the player "deliberately" touches the rook first. Presumably, if Nepo had done so, he would have lost the appeal.
The Chess960 rules do recommend that players take certain precautions when castling:
When castling on a physical board with a human player, it is recommended that the king be moved outside the playing surface next to his/her final position, the rook then be moved from its starting position to its final position, and then the king be placed on his final square.
To avoid any misunderstanding, it may be useful to state "I am about to castle" before castling.
But these are just suggestions. Players are not required to follow them.
Meanwhile, what happened in 2022 was much more straightforward: Wesley played a move under the mistaken belief that he would be able to castle out of check. By the time the arbiters explained to him that this was not legal, So's move and Nepo's reply had already been made. A move does not become invalid merely because its player misunderstood the rules, even if the player's misunderstanding causes them to blunder. You can tell the arbiter that you (e.g.) "didn't know about en passant" until you're blue in the face, but they're not going to void your game on that basis.