What is Mercutio's relationship to the play Romeo and Juliet?
Mercutio is Romeo's best friend. He is also a kinsman of the Prince.
As for the relationship to the play, he functions as the comic relief. Shakespeare realized that in a tragedy, it was necessary to relieve tension created by the circumstances in the story. The best way to do this is through comic relief. Until his death, Mercutio is a jokester. He doesn't seem to take anything seriously. Life seems to be a lark for him.
The fight between Mercutio and Tybalt is just playing around for him. The reality that he or anybody could be killed doesn't enter his mind, it is all just blowing off steam. I think he is very surprised that he has been morally wounded.
Of course his death is important for several plot reasons. Romeo kills Tybalt and is banished although earlier the Prince had declared that if any broke the peace they would die. Since it was Tybalt who started the whole thing and Romeo was avenging the death of his friend and the Prince's kinsman, the Prince relents and banishes Romeo.
Mercutio's relationship to the play is important because his death triggers the resulting deaths of both Romeo and Juliet.