Rosaline is an interesting character. For one thing, she never actually appears on stage. She is, however, useful to Shakespearse.
First, she illustrates Romeo's youthful passion. He is completely infatuated with this young woman who has never even spoken to him and who plans to remain chaste by entering a convent. This helps the audience to accept Romeo's later instant attraction to Juliet.
More importantly, Rosaline is the flame that attracts the moth. When Romeo reads the guest list for the Capulet feast and discovers Rosaline's name there, Benvolio has no trouble convincing his friend to crash the party. Of course, that is where Romeo meets Juliet, and the wheels are set in motion for a fine tragedy.