Why doesn't the computer take my knight? [FEN "3r4/p1p1kp2/1pn1b2p/4P1p1/P3pN2/2P1P1B1/2P2PPP/R5K1 b - - 0 1"]

 1...Nxe5 {This was the original question with black to move.} (1...gxf4) (1...Rd2)


NB: Black's knight was on C6 and has just moved to e5 and captured a pawn.

So I'm a beginner, playing the chess.com app on level 5 and periodically turning 'show best moves' on and off. I'm playing white; I got my white knight cornered on h3 so at the computer's suggestion moved it to f4, fully expecting black's pawn on g5 to capture it. It's what I would do. But instead black moves Rd2. Surprised, I try again on level 20; this time black moves Nxe5. 

Why are Rd2 and Nxe5 better than gxf4?
If I understood correctly, the knight was on c6 and you play Nf4 whilst having a pawn on e5 still (which is important as it prevents f6 by black after gxf4 Bh4+). In this case, gxf4 is not necessarily the best as it leads to the exchange of B+N for a rook an a pawn (see below), which gives white some chances, despite it still being better for black.

 [title "Game position before Nf4, white to move"]
 [fen "3r4/p1p1kp2/1pn1b2p/4P1p1/P3p3/2P1P1BN/2P2PPP/R5K1 w - - 0 1"]

 1. Nf4 gxf4 2. Bh4+ Ke8 3. Bxd8 Kxd8 4. exf4


Instead, considering that white's lacking both coordination and activity, and the fact that black has all pieces centrally established and controls the only open file, it might be simpler (and even best) to not create an imbalance (like the line we saw above) and aim to maintain the assured edge by avoiding an over simplification that might be hard to judge and playing against white's shattered queenside pawn structure. Here's one possible continuation to exemplify:

 [title "Game position before Nf4, white to move"]
 [fen "3r4/p1p1kp2/1pn1b2p/4P1p1/P3p3/2P1P1BN/2P2PPP/R5K1 w - - 0 1"]

 1.Nf4 Nxe5 2.Ne2 Kf6 3.Nd4 Rd5 4.Kf1 Rc5 5. Ra3 Bd7