if you don't mind not owning it, then google music, amazon music and so on are great options. they each let you listen to unlimited music and let you download stuff for offline listening. once you let the subscription expire though all the music goes away with it.
but for not much cash each month, you can listen to just about anything and everything out there. there are no free solutions to do the same thing. you either buy it outright or "rent" it through one of the subscriptions. i like google music myself as it does not limit what you can listen to. amazon and some of the others don't open the full catalog and lots of new music or even a couple songs from a cd are not part of the service are must be bought separately. with google if it is on the app, then it is part of the subscription. also get the bonus of youtube red/premium or whatever they are calling now which removes youtube ads and allows for listening while doing something else on mobile and even downloading for offline viewing later as well.