Most likely White had taken this move into account, but missed something further on.
Very imaginative! Black has not castled, yet the capture of this pawn will speed up an initiative on the kingside.
On 22...Rxh6 23.Qg8+ Bf8 24.Nf5 wins back the rook, preserving a much better position.