For the most part, I agree with the previous answer, but just because it is a comedy, does not mean there is not a serious intent behind asking for the rings.
As with most of Shakespeare's comdies, the women teach the men. In this case, they teach their husbands that when they vow to never give their wedding rings (the eternal symbol of love and marriage) away, they must keep that vow. By giving his ring to the disguised Portia, he is putting Antonio's urging above the vow made to his wife. When she gave him the ring, (Act II, scene 2), she told him,
............... I give them with this ring,
Which when you part from, lose, or give away.
Let it presage the ruin of your love,
And be my vantage to exclaim on you.
I would call it a test. Portia is not just a beautiful and wealthy women, she is highly intelligent and Bassabio must realize that she does not give him everything, symbolized by the ring, without expecting him to also fully commit. By accepting the ring, he is telling her that he accepts her love and everything else on the terms she laid down.
It is curious that Antonio "hangs Bassanio out to dry"so to speak when Portia confronts Bassanio about the ring in Act V.
Narissia, on the other hand, is the more comic of the two. She is also paired with Grationio, a more comic character than Bassanio. She just does what Portia does.
The end result is that both men learn a valuable lesson about making and keeping vows.
This short scene follows the much longer and far more complex court scene in Act IV scene i. Having saved Antonio, Portia, dressed up as the famous lawyer, now is offered a gift of thanks from Bassanio. In the end, she manages to gain her ring back, that Gratiano gives her. Seeing how Portia has tricked Bassanio, Nerissa resolves to do the same to Gratiano and to get his ring.
Clearly both Portia and Nerissa do this with comic intent, and we are forced to recall that, in spite of appearances otherwise, especially in the last scene, this play is denoted a comedy, and not a tragedy. Therefore we anticipate a light-hearted conclusion at the end of the play concerning the rings when the resolution reveals all.