Yeah but, here's what I don't understand... (It's important we understand what's going on before starting deleting anything)
I assume all the photos were originally on your Mac only and were synced first to the cloud when iCloud photo library got enabled, they would then have been synced to your phone.
Now what doesn't make sense is that your phone is now trying to sync them back to the cloud, when one would assume they were already there. Secondly, you have optimisation turned on and optimised photos can't be synced to the cloud. If they weren't optimised it would be possible to sync them to the cloud, but they would take up a lot of room on your phone, perhaps more than all but the largest capacity phone can hold.
So...
- What size phone do you have.
- Have you turned iCloud photo library on and off on the phone at all.
- How many photos do you see at iCloud.com in your browser on your Mac.
- Are all the photos you should have on the mac there.
- Are there any photos on the phone that you want to keep that aren't elsewhere.