Black's only capture is of the a1 rook, so the h7 pawn has to promote without leaving the h-file. It and the rook at h2 have to both be in place before the white gh pawns are in place, and then there's no way for the white king and rook to trade places.
With the white king and rook swapped, it's easily legal.
It would be nice if you could find a position whose illegality is less obvious.