Apple Inc. wants to regain the beat in its music business, which is under assault from a stream of upstarts.

The tech giant said on Wednesday it is buying Beats Electronics LLC for $3 billion to bolster a music business that has lost some of its mojo, as streaming-music services encroached on the downloads dominated by Apple's iTunes service....