Why is white's best play Nxd5 here? I'm new to chess. In the position below, lichess analysis says that Nxd5 is the best move for white. But can't black just capture the knight afterwards with his pawn and threaten white's pawn and rook in the top right hand corner after white's knight is dead? What makes Nxd5 the best move here?

 [FEN "r3k3/p5R1/p1p4r/2bbp2p/8/P1N3KN/1P5P/R7 w q - 0 1"]
First, you have to understand that computers sometimes play non-human moves because they see things that humans most times do not. It probably sees threats to the white king based on the black bishop pair.

In this position, white is just lost, and those bishops on d5 and c5 working together are incredibly strong, so trading off one of them is desirable. What makes it a little strange is that it gives black connected passed pawns, but they are hard to maintain, let alone advance, due to the active white rooks, and unfortunate black Ra8, but it still does not change the outcome.

Also, the Ra8 is not lost to Nd5 cd; Rg8 Bf8; Rf1 Ke7, but it does tie black up some, which is another reason that Nd5 was best. It is hard to finish his development.

 [FEN "r3k3/p5R1/p1p4r/2bbp2p/8/P1N3KN/1P5P/R7 w q - 0 1"]

 1. Nxd5 cxd5 2. Rg8+ Bf8 3. Rf1 Ke7 4. Rf5 {with a little counterplay that requires accuracy from black} Rf6! 5. Rxh5 (5. Rxe5? Kf7 6. Rh8 Bd6 7. Rxa8 Bxe5+ 8. Kg2 Bxb2 9. Rxa7 Kg6-+)  Rc8! 6. Rxe5 Kd7!! 7. Rd5 Bd6+ 8. Rxd6+ Rxd6 9. Rg7 Kc6 10. Rxa7 Kb6 {with an easy win from here}