Music streaming services typically obtain licenses from record labels, publishers, and performing rights organizations to stream their catalog of songs legally. They then pay royalties to rights holders based on factors like the number of streams and subscriber revenue, with different agreements and rates for each song or artist.