Also it is important to note that by including the lottery of the chests into the play, Shakespeare is making not only a play on words, but a satirical comment on the nature of parental selected marriages. Portia must fight her own free will or her desire to pick the suitor of her choice based on marital qualities she finds important vs. her dead father's actual will (hence the play on words--free will vs. actual will) who has outlined very specific tasks which must be achieved before Portia's hand can be won. What is a girl to do? Obey her father who is already dead and won't have to deal with her husband for even 1 day or follow her own instincts and pick who she desires?
The ridiculous lottery is silliness at its best, a true reflection of how Shakespeare feels about these types of contests as evaluations of life mates!
Good question. There are a number of reasons to use this plot device.
In a general sense, Shakespeare's period put more attention on the effects of fortune, even evoking fortune (fate, chance) as a kind of natural force in the universe. This device introduces an element of fate. On the plot level, it also introduces mystery; who will choose the right chest and prove himself worthy of love? On the level of characters, the choices made show the nature of the character doing the choosing; it is one of the many mechanisms in Shakespeare for showing character.
It was trying to tell us that you should not follow your own "desire" as it is very unreliable guide and would lead you to temptation. It should be resisted and not overcomed. It was represented in this part of the story:
Bassanio must ignore the gold casket and the silver casket to win Portia. The correct casket is lead and warns that the person must risk everything he have.
It also have another lesson to teach. Appearances are very deceiving and you should not take everything at face-value, hence the ordinary-looking representation of the lead casket.
I would have to say that I do not agree with the past two answers. The lottery of the chests is known in theatrical terms as a "faux ami" that is a false friend. We watch the casket tale unfold and then when Bassanio chooses right we believe that this is the climax of the play. But then the court trouble begins. To summarise the caskets is an anti-climax