Optimize storage works by keeping only screen-sized images locally on the phone and relying on iCloud to hold all the necessary support files. For example, on my phone, almost every one of my pictures is optimized, but some that I have edited recently will have the full data still stored locally.
If you turn off iCloud Photos, then you are given the option of downloading the entire Library:

If, instead, you select Remove, then all the screen sized images (probably all of them) will be deleted from the phone, since they aren't much good without the iCloud support. The few pictures that have all their data locally may be retained--I'm not quite sure of that, since I haven't tried it. The full Library would remain at iCloud.com as long as the storage is paid for.
In your case, as may happen with most people who need to optimize, there isn't enough room on your phone to hold all your pictures, so you aren't given the choice to Download. You can Cancel and continue as before, or you can continue to turn off iCloud Photos, and all your pictures will remain at iCloud. You could download them to a computer from iCloud, but that's rather awkward for lots of pictures.
If you downsize iCloud, and if there isn't enough room left for all your pictures there, then they will be erased from iCloud, forever.
You could, and should, just plug in an external drive, select the pictures, and use Share>Save to Files. This provides a solid backup of your Library. You should probably save both Unmodified Originals and the regular edited versions. Alternatively, you can backup to a computer:
Transfer photos and videos from your iPhone or iPad to your Mac or PC