I know, Merry. But Riv wasn't asking what Aragorn was doing in Mordor. She wanted to know why he went there, and my answer is bascially that it was just something he had to do, probably even felt compelled to do.
Now, if you're asking for speculation on what he might have been doing there, my guess is that he was spying out the situation at Minas Morgul and around the Black Gate, maybe also around Cirith Ungol. He does specifically mention the first two places in the quote above.
Did his time in Mordor include an encounter with one or more Ringwraiths? I don't know. We know that he HAS encountered them at some point in his life because he clearly implies this in his first conversation with the hobbits in Bree:
"They will come on you in the wild, in some dark place where there is no help. Do you wish them to find you? They are terrible!"
The hobbits looked at him, and saw with surprise that his face was drawn as if with pain, and his hands clenched the arms of his chair. The room was very quiet and still, and the light seemed to have grown dim. For a while he sat with unseeing eyes as if walking in distant memory or listening to sounds in the Night far away.
"There!" he cried after a moment, drawing his hand across his brow. "Perhaps I know more about these pursuers than you do."
I do love this moment, because it is perhaps one of the most vulnerable moments for Aragorn in the entire tale. However, it gives us practically no clues for when this event took place in Aragorn's timeline. We do know from Appendix B that Sauron did leave 3 of the Nazgul in command of Dol Guldur after his withdrawal to Mordor in 2941. So I do wonder if Aragorn's reference to "They will come on you in the wild, in some dark place where there is no help," isn't a hint that his encounter with the Ringwraiths was somewhere outside of Mordor "in the wild."
Did he encounter them on one of his visits to Mirkwood (with 3 Nazgul stationed in Dol Guldur, that's entirely possible)? Or on patrol with the Dunedain somewhere in the North in the Witch King's former domain? Or on his sojourn to find Gollum? Personally, I find these scenarios to be far more likely than the possibility that Aragorn encountered one or more Ringwraiths during his time spying about in Mordor. I just don't believe he could possibly have survived such an encounter within Sauron's domain. He may have felt the presence of one or more of the Nine within Minas Morgul, and that certainly would be terrible enough! But I just can't envision a scenario in which Aragorn could have prevailed in an encounter with a Ringwraith inside Mordor where their Master's power, even without the Ring, was so terrible and nearly absolute.
I do think Aragorn probably endured terrible privations, not to mention several dangerous scuffles with orcs (Angie over at the former WRoR posted a series of WONDERFUL stories imagining what Aragorn's sojourn in Mordor might have been like, along with Arwen looking out for him from afar through her Grandmother's Mirror -- too bad we can't access them any more!). We should recall that Sam does overhear Shagrat mentioning encountering "filthy tarks" and saying, "He's got past the Watchers, and that's tark's work." A "tark" is Black Speech for a man of Gondor. I wonder if this refers to some of Aragorn's spy work during his time in Mordor?
Whatever happened while in Mordor, Aragorn emerges as a man truly tempered and hardened by fire. I think it is no coincidence that this horrible episode is followed by a period of time in Lothlorien in which he is reunited with his lady love and Arwen commits her life to him. No, he isn't yet the King of Gondor and Arnor, but in her eyes (and we must assume also in Galadriel's eyes), he is fully worthy of her love. He has passed through the fire and emerged the Warrior-Priest-King Apparent.
The fact is, we'll never really know what happened while Aragorn was in Mordor, but it is fun to speculate, isn't it?