White must clearly do something with his g-pawn, and there is no better time to push it than now, so 1.g7. (It's remarkable how many endgame studies begin by pushing a pawn to the seventh rank.)
If Black tries to stop the pawn with 1...Rb8, White cuts the rook off with 2.Nf8, winning comfortably even if he has to surrender his rook for the black g-pawn. So after 1.g7, Black's only hope is 1...g2.
White continues 2.g8=Q, and it looks simple: after 2...g1=Q+ 3.Qxg1+ Kxg1, White picks up the rook with 4.0-0-0+! Very neat, but there is far more to it than that. Instead of promoting his pawn, Black plays 2...Rc2! White's queen has no check and 3.Ra2 Rxa2 4.Qxa2 Kh1! leads only to a draw.
The answer is most surprising: White continues 3.Nf6 g1=Q+ 4.Qxg1+ Kxg1 5.Ng4! White has no threat, but Black has no move. 5...Rb2 loses to 6.0- 0-0+, 5...Rc3 to 6.Kd2+, 5...Rc4 to 6.Ke2+ Kg2 7.Ne3+, 5...Rg2 to 6.0- 0-0 mate. Since 5...Kh1 loses to 6.Ne3, that leaves only 5...c4 6.Ne3! Rh2 (or Rf2) 7.0-0-0+ Kf2 (Kh2) 8.Ng4+ and White wins.