Mercutio provides most of the comic relief in the play. This allows the audience to laugh in between the more serious parts of the play. I think Shakespeare felt his audience needed this relief in order to get through the tragedy of the death of Romeo and Juliet at the end. When Mercutio is killed by Tybalt, this begins the unraveling of the plan the Friar has put together for the couple. The audience then knows that tragedy is to follow when the fun-filled, humorous character of Mercutio is slain. Mercutio also plays a foil to the serious character of Romeo.
Mercutio is introduced in act 1 scene iv as he and Romeo go to crash the Capulet party. The scene captures the essence of Mercutio as a joking foil to Romeo who gets Romeo to not take life so seriously. Shakespeare uses Mercutio as a character that creates things to happen and then uses Romeo as the one to act. For example, although it is Mercutio's idea to go to the party, Romeo is the one who ends us falling in love. And while it is Mercutio who begins the fight with Tybolt, it is Romeo who ends up killing him, and getting banished. It is theorized that Shakespeare kills of Mercutio because he was getting to be too interesting a character. With his wit and jest, to let him live would pull attention away from Romeo and Juliet.
There is a very good and full article all about the character of mercutio here: http://www.enotes.com/romeo/777
Mercutio is Romeo best friend, intensely witty and funny, satirical and full of imagination . He is the "clown joker" and the prankster of the play as he keeps on teasing Romeo relentlessly. He is a "scene-stealing" character in the show with his famous of his puns "ask for me tomorrow, and you shall find me a grave man" about his timely death that makes him a memorable and lovable character. He provides comic relief and entertainment to this tragic drama, to provide some laughter to the audience during different parts of the play. He is not always all fun and play, he has some seriousness to his nature. He hits hardly on romantic sentiments and blindly self-love that exists throughout the entire play.
He was killed when Tybalt stabbed him under Romeo's arms when he tried to stop the both of them, not without cursing both of the families: “A plague o’ both your houses”. His timely death make Romeo so mad and distraught that he was forced to engage with Tybalt a sword-fight and he was the ultimate victor when he slain Tybalt. This part proves to be a breaking point as the whole tragedy unfolded. Romeo was banished and exiled to the exterior of the town and was therefore separated from Juliet.
The purpose of his death was to divert the attention away from it and direct it to the centralized part of the story- the tragic tale of two lovebirds. It was also to let the fatal date unfold even further and cause more discomfort and grief
Mercutio persuades Romeo to go to the Capulet party. He's also a bit of comic relief. He was also killed which made Romeo go ballistic and kill Tybalt, causing banishment and drama drama drama. ^-^