The king cant castle through check.
Why is castle illegal?

You can't castle through check. You can't castle to get out of check. You can't castle into check. You can't castle if there is a piece in the way. You can't castle if the King or Rook has already moved.
... I think those are the only restrictions.
I arrived at a position today where I could not castle and I can not understand why that is. Please explain.
The game: https://www.chess.com/live/game/1925913982