Ophelia's funeral in Shakespeare's Hamlet serves many purposes in the play.
The funeral contributes to themes in the play such as death and dying and madness. Her death is caused by her madness. It also follows the graveyard scene, so, in addition to death and madness, the theme of rottenness is present, too. The funeral provides a symbol of the state of existence in Denmark, and is emblematic of the tragedy that is in the process of occurring.
Also, the funeral provides occasion for Hamlet to confront Laertes, and vice-versa. They are bitter toward each other and this will continue with the duel in the closing scene of the play.
Finally, the funeral brings Hamlet out into the open, making it official that he is back in England. This scene is the starting point for the play's descent toward the tragedy.