(The above rendering comes from the RJPS translation, an adaptation of the NJPS translation. Before accounting for this rendering, I will analyze the plain sense of the Hebrew term containing אִישׁ — or in this case, its plural אֲנָשִׁים.)
In the nominal phrase שְׁנַֽיִם־אֲנָשִׁ֤ים מְרַגְּלִים֙, the head noun אֲנָשִׁים plays its usual situating function on the discourse level: it marks its referent as essential for grasping the newly depicted situation. (Contrast this introductory frame with 1 Sam 26:4: וַיִּשְׁלַ֥ח דָּוִ֖ד מְרַגְּלִ֑ים — there אֲנָשִׁים is not appropriate because the situation is construed not as new but rather as given, and the spies are construed as an extension of David’s ongoing activity.) Likewise, English classically uses the situating noun men to tag a situation-defining participant, especially upon introduction into the discourse.
The verse makes a rough specification of the referents’ gender according to social-gender agreement (namely, at least one of the two is a man). However, the frequent use of אִישׁ elsewhere without regard to gender, in non-specific reference, shows that the specification of gender here is secondary to the referents’ individuation and location within the situation.
Here, the military context restricts both referents’ gender to being men; it goes without saying.
As for rendering into English, in this language a specification of gender upon introducing a figure into the discourse is customary and expected. Here it has a happy result, in two respects: (1) it makes their arrival at the house of a prostitute easier to grasp, and, more importantly, (2) this episode revolves around the contrast between the manly characters (spies, the king of the city) and the womanly one (Rahab). That is: like in the opening story of Exodus (i.e., the tale of the midwives), it is Rahab, a “triple marginalized woman” (Frymer-Kensky, Reading of the Women of the Bible, 35) who orchestrates this story. The specification of “men” here thus prepares the ground for this contrast.
The NJPS rendering ‘two spies’ is conventional in treating אֲנָשִׁים as having no translation value in the Hebrew expression (so also OJPS, REB, NLT, NIV). For RJPS, the rendering ‘two men … as spies’ is preferred, in order to engage the situating and gendering functions of the noun men in English.