I somehow got my iPhone in a state where half of my library wouldn't download. I'd just get the "unable to download" error for many songs I'd previously downloaded and were no longer local. I'd switched off iCloud Music Library, switched it back on, and made sure all music was no longer on my phone. I couldn't even stream them from Apple music. Nothing fixed it until I removed the offending songs from my library and re-added them from Apple music. Then they'd download.
Obviously with an over 3000 song library this isn't a solution that will work so I dug in to the media folder with iExplorer.
My fix ended up being this:
1) Back up the phone. Also in iTunes run: File-Devices-Transfer Purchase to make sure purchases are synced to your computer hard drive. Make sure to also export your photos for safe keeping. Alternatively you can copy the DCIM directory to your hard drive manually using iExplorer.
2) Disable iCould Music Library (on the iPhone under settings-Music.)
3) Open up iExplorer and connect the phone.
4) In iExplorer look at your phone (device) and under it you'll see "Media." Select Media.
5) There is a directory "Purchases." Delete it (or at least everything in the directory.) This director appears to contain a cache of all of your offline downloads. Apparently what was in there and what the database thought was in there got out of sync.
6) For safe measure, I reboot the phone. The OS will re-build missing directories on boot if it needs to.
7) Turn on iCloud Music Library, allow it to load, then try downloading your music. It should work.
* DO NOT DELETE the "Downloads" directory. It contains a database file of your app updates. If you delete this file you won't be able to do OTA app updates until you've done a backup>factory reset>restore from backup.
I actually worked this in reverse. I took everything off my phone (in iTunes I unsynced everything and offloaded my photos.) Then I deleted everything in the media folder EXCEPT "Downloads" and "Purchases." I noticed it didn't fix the problem so I then deleted "Purchases" and it did fix the problem. Note, doing iTunes will ask you to set the iPhone up as a new phone when you connect it. It's not a bad way to "nuke everything" when the stuff hits the fan (delete everything in Media except for Downloads.)
Just never never delete "Media/Downloads" or you'll have to do a factory reset/restore from backup to fix it. And that requires you to have to re-scan fingerprints and re-setup Apple Pay.
Simply deleting "purchases" should do it.
iExplorer is here https://www.macroplant.com/iexplorer/
This isn't without risks so please back up everything.