En passant only occurs when opponent’s pawn advanced 2 squares and your pawn is side-by-side to them. In this position, Black played 21…g5. Yet Black’s pawn advanced 2 squares, but your pawn is not side-by-side to them. So, en passant can’t occurs.
The game didn't allow me to take en passant and my K isn't in check, why?
To say the same thing again: en passant would be allowed if your pawn were on f5. Then 21. ...g7-g5 could be followed by 22. f5xg6. Notice that your pawn ends up on g6.
The reason for the en passant rule is so that even if the black pawn skips past the g6 square with a two-square advance, it can still be captured by a pawn attacking g6. Your pawn isn't attacking g6, so en passant doesn't apply.
The last move is 21.. g5
I have no clue why I couldn't take en passant.