There are a few recently contrived words that try to do this; optionality is indeed used from time to time, and I've seen things like mandatoriness too. But actually there are some more established words that do the same job.
Of course, optional-ness is actually binary - something is either optional or mandatory. Therefore the quality of optionality/optional-ness is actually the same as the quality of mandatory-ness or compulsory-ness, just with the polarity reversed.
All of which is a fairly long winded way for me to get around to saying this:
I think the word you're looking for is the noun, necessity.