These musical numbers play an important role in character development. Ballads and slower pieces often convey deep emotions of sorrow, loss, love, or despair while up-tempo numbers allow a character to express their joy, elation, or excitement. Often, musical numbers are written for more than one character. The 'love' duet is a common inclusion in any musical. Also, ensemble numbers, featuring many or all cast members are usually highly energetic song and dance extravaganzas.
Duets allow characters to communicate their feelings for one another.
They are often used at climactic parts in the plot. Ensemble numbers often close an act or may even be the opener in a show. For this author, I begin writing my dialogue and advancing the plot of my story as a play. I envision my characters in the fully staged version of my musical and try to get a feel for those places where a musical number could enhance the plot or help the audience empathize with a character's situation. I also look for places in my writing where a musical piece can take the place of the spoken word.