Examine the Black king’s position. If White safely could play RxR on f8 the game would be over; but Black’s queen guards the rook and so prevents this. This makes the queen vulnerable to attack, as it cannot afford to leave its post to defend itself. Consider ways of going after it. If White attacks the queen with Qc2, Black can reply by simply moving it to d6 where it still does the same defensive work. White needs a way to threaten Black’s queen while also threatening something else. Black’s other pieces have guards or are inaccessible, so what else can White threaten? Again, focus on Black’s king. White’s rook not only threatens RxR; it also attacks a square next to the king (g7). If White’s queen were aimed at that square, it would threaten mate. So White does have a double attack: with Qe5 he can attack both g7 (a mating square) and Black’s queen (another vulnerability—it can’t strike back). Something has to give, and it’s the Black queen. Black plays RxR to avoid mate, but then suffers QxQ and the game is over anyway.
The point, of course, is that once the enemy queen becomes a good target for a fork because it can't afford to move, you can combine it with all sorts of other threats: attacks against other loose pieces, attacks against the king, or—as here—attacks against mating squares. To see this last option you need to be alert to multiple mate threats you can make. By assumption you already see one—RxRf8; that's how you realized that Black's queen couldn't move. The trick is to remember there might also be a different one that then can be made the basis of a fork: you can add a threat by your queen against g7.
Notice, finally, that the same effect could be achieved in a more roundabout fashion by pursuing that first idea—Qc2—a little farther. We saw that Black can reply with Qd6; but then if White plays Qd2 he attacks Black’s queen again. Black moves it back to c5, creating the same position seen in the diagram but with White’s queen now on d2 instead of e2. White then can play Qd4, again forking Black’s queen and the mating square g7. The reason to bother noticing this is just to remember that sometimes there may be more than one forking square and more than one way to get there. Since perfecting such a fork ends the game almost as surely as checkmate, it is worth carefully studying all the ways you might make it work.