Portia's father left a strict clause in his will regarding his daughter Portia's inheritance in The Merchant of Venice by William Shakespeare. If she wants what he has left for her, she can only marry the man who wins her through what Portia refers to as "the lottery of my destiny." All suitors must open one of three boxes (called "caskets" in the play); the suitor who chooses the correct box (the one with her picture in it) wins her hand in marriage. Even more, any suitor who opens one of the boxes must agree never to marry, even if he chooses incorrectly.
The first speech in Act II scene i is spoken by a Moorish prince who politely asks Portia not to discount him as a proper suitor just because he is dark-skinned. Portia replies that she is not allowed to choose who is and is not a proper suitor but says if she were allowed to choose, he would be
As any comer I have look'd on yet
For my affection.
Of course, this is not saying much, as Portia is not interested in any of her suitors.
The Moor then gives the speech to which you refer in your question:
Even for that I thank you:
Therefore, I pray you, lead me to the caskets
To try my fortune. By this scimitar
That slew the Sophy and a Persian prince
That won three fields of Sultan Solyman,
I would outstare the sternest eyes that look,
Outbrave the heart most daring on the earth,
Pluck the young sucking cubs from the she-bear,
Yea, mock the lion when he roars for prey,
To win thee, lady. But, alas the while!
If Hercules and Lichas play at dice
Which is the better man, the greater throw
May turn by fortune from the weaker hand:
So is Alcides beaten by his page;
And so may I, blind fortune leading me,
Miss that which one unworthier may attain,
And die with grieving.
The prince thanks her for acknowledging his suitability as a potential husband and then says he wants to take his chance by opening one of the boxes. He claims that he would endure great hardships and show great bravery in battle against both man and beast for the opportunity to win Portia as his wife; however, even great, heroic figures (such as Hercules) are not assured victories when they are playing a game of chance ("blind fortune"). Because it is a matter of luck, the prince may lose his opportunity to marry Portia to someone far less worthy than he is, which will cause him to "die with grieving" (metaphorically, of course).