You either need to offload pictures to somewhere else to archive them, or get a device with more storage. iCloud photo and iCloud in general is a service to simply sync data, not archive it. See Set up and use iCloud Photos - Apple Support
”Here's how it works
iCloud Photos automatically keeps every photo and video you take in iCloud, so you can access your library from any device, anytime you want. Any changes you make to your collection on one device, change on your other devices too. Your photos and videos stay organized into Moments, Collections, and Years. And all of your Memories and People are updated everywhere. That way you can quickly find the moment, family member, or friend you're looking for.”
and
”Make sure that you have enough storage
The photos and videos that you keep in iCloud Photos use your iCloud storage and your device storage. And as long as you have enough space in iCloud and on your device, you can store as many photos and videos as you like.”