Q:

Chess problem question; why is this the solution?

[fen "5B2/3p1n2/R2p4/1P1NRBQ1/1KPkrb2/1p6/2Pp1Pn1/4r3 w - - 0 1"]

1.Nc7 Rxe5 (1...Nxg5) (1...d1=Q) 2.c3#

What would make you play Nc7? This results in checkmate in 2 if, as the computer does, Rxe5 is played, but why wouldn't the computer just play Nxg5, winning the queen and preventing checkmate? Or d1 and promote to a queen? 

A:

What would make you play Nc7? 

It is the only move with which White can give check mate in two moves.

This results in checkmate in 2 if, as the computer does, Rxe5 is played, but why wouldn't the computer just play Nxg5, winning the queen and preventing checkmate? 

On 1. ...Nxg5 White plays 2.Rd5 which check mates.

Or d1 and promote to a queen? 

On 1. ...d1Q White plays 2.Rd5 which check mates.
SUMMARY:
1.Nc7 has been played to free the rook on e5 to give check mate, by coming to d5.
This is why computer played 1. ...Rxe5, since on every Black's move 2.Rd5 check mates, except for these:
1. ...Ne3 but then White mates with 2.Rxe4.
1. ...Nxe5 where White mates with 2.Rxd6.
1. ...Bxe5 where White mates with 2.Qxd2.
1. ...dxe5 where White mates with 2.Bc5.
1. ...Kxe5 where White mates with 2.Bg7.
Best regards.

