Shakespeare contrasts Mercutio’s crassness with Romeo’s naiveté in order to emphasize Romeo’s youth and inexperience.
Romeo and Mercutio are both immature, but they demonstrate their immaturity in different ways. Romeo is pining for his lost love, Rosaline, and then obsessed with Juliet. He is the romantic. Mercutio is crass and playful. He talks in puns. He has more of a temper than Romeo, and is more interested in fighting, whereas Romeo is naïve.
Mercutio is Romeo’s friend. He does not take things as seriously as Romeo does. When Romeo is pining for Rosaline, the girlfriend he lost, Mercutio tries to tease him into moving on.
…You have dancing shoes
With nimble soles; I have a soul of lead
So stakes me to the ground I cannot move.
You are a lover. Borrow Cupid's wings
And soar with them above a common bound. (Act 1, Scene 4)
Like most friends, they banter. It is more like locker room talk. Mercutio likes to make jokes (in puns). Romeo is calmer, and gentler. He does not like to take part in the raunchy humor as much. He is more earnest.
By creating a character like Mercutio, the typical man’s man, Shakespeare emphasizes Romeo’s naiveté and gentleness. He is not like the other boys. It may be one of the traits that Juliet likes about him, but it is also what causes his downfall.
An example of Mercutio’s temper, and Romeo’s contrast to him, is in the fight with Tybalt. Romeo does not realize that he is interfering when Tybalt and Mercutio are dueling. He tries to stop the fight, and that actually ends up getting Mercutio killed.
Zounds, a dog, a rat, a mouse, a cat, to scratch a man to
death! a braggart, a rogue, a villain, that fights by the
book of arithmetic! Why the devil came you between
us? I was hurt under your arm. (Act 3, Scene 1)
Mercutio’s temper is what caused him to want to fight Tybalt instead of turning back, but he also has the maturity to realize that a fight is unavoidable. Romeo does not. Romeo’s inexperience and naiveté lead him to get in the middle of the fight and, as Mercutio points out, it is actually that which leads to Mercutio’s death. Then Romeo has to finish the fight anyway.
Romeo’s youth and inexperience, as contrasted with Mercutio’s worldliness and crassness, go a long way to explaining the trouble he gets himself into as the play goes on. They lead him to his doom, partly. The rest is really fate, as Shakespeare would have us believe by the prologue! Romeo may be young and make bad choices, but if there had not been a feud to begin with, things would not have gone quite so badly.