The friendship serves four dramatic functions:
Mercutio is worldly, witty, combative; Romeo is idealistic, romantic, gentle. This foil highlights Romeo's innocence.
Mercutio's bawdy humor and "Queen Mab" speech (I.iv) provide levity, making the eventual darkness more striking.
Through Mercutio, Romeo gains worldly awareness; their banter forces him to articulate and test his feelings.
Mercutio's death (III.i) is the turning point. Romeo's grief-driven revenge killing of Tybalt leads directly to his banishment—the structural pivot to the final catastrophe.
Without this friendship, the play loses its emotional architecture: the laughter that makes the tears heavier, the friend whose death makes the lover a killer.