No one is really sure of Shakespeare's motives in writing this prologue. However, the prologue to Romeo and Juliet sets up the story very effectively.
It would be very common in Shakespeare's time for audiences to know all about a story before they ever saw it acted onstage. So, it's not unusual that the prologue sets the scene and tells everything that is happening in the play before it even begins.
The great thing about this prologue, though, is that it really adds weight to the "star crossed lovers" theme by increasing the sense of fate.
From the very beginning, the fate of the young lovers is already decided. This theme of fate weaves its way throughout the rest of the play and is underscored by the prologue itself.
So, while we don't know exactly why Shakespeare wrote it, we certainly know why it is a perfect way to start the play.