If you are using iCloud Photos on your iPhone, then if you delete photos from your device, they will be deleted from iCloud. iCloud Photos is a syncing/sharing service, not an archival one. When you are using iCloud Photo Library, you are basically opening a window on your Photos Library. So, anywhere that you have iCloud Photos turned on, you are looking at the same library, and anything you do to the photos in that library (from any source), is going to be reflected across the board.
If you turn on the Optimize Photos feature, you enable iCloud and the device to work together to ensure that the number of full-resolution photos actually downloaded to your device are managed so that your device continues to have enough storage to continue to work properly. However, if you have an extremely large Photos library, then you would get to a point of diminishing returns, and eventually, you would run out of space on your device.
You can download a number of photos from iCloud to a photos app on your computer so that they can be removed from iCloud altogether.
Or, you can turn off iCloud Photos on the device, and sync photos back to it directly from your computer's Photos library:
Sync your iPhone, iPad, or iPod touch with iTunes on your computer using USB - Apple Support
Best,
GB