If you take the sample GRIB file "GRIB2.tmpl" and dump it, you can see which keys are MISSING (i.e., their values are all 1's) but it is not possible to see which keys can be MISSING. So for example take the key "iDirectionIncrement":

% grib_dump -O GRIB2.tmpl
iDirectionIncrement = 2000000

So in this case its value is not MISSING but it is possible for this value to be MISSING. This is not indicated here. 

So whereas one can set the "iDirectionIncrement" key to MISSING, one cannot do this for another key which cannot be MISSING. For example:

% grib_set -s longitudeOfLastGridPoint=missing GRIB2.tmpl out.grib
ECCODES ERROR   :  unable to set longitudeOfLastGridPoint=missing (Value cannot be missing)

The solution is to use the "-D" option of grib_dump and look for the string "can be missing".
Let's try that:

% grib_dump -D GRIB2.tmpl | grep 'can be missing'
79-83 unsigned subdivisionsOfBasicAngle = MISSING (can be missing)
100-104 unsigned iDirectionIncrement = 2000000 (can be missing) [Di, Dx]
104-108 unsigned jDirectionIncrement = 2000000 (can be missing) [Dj, Dy]
123-125 unsigned hoursAfterDataCutoff = 0 (can be missing) [hoursAfterReferenceTimeOfDataCutoff]
125-126 unsigned minutesAfterDataCutoff = 0 (can be missing) [minutesAfterReferenceTimeOfDataCutoff]
132-133 signed scaleFactorOfFirstFixedSurface = MISSING (can be missing)
133-137 unsigned scaledValueOfFirstFixedSurface = MISSING (can be missing)
138-139 signed scaleFactorOfSecondFixedSurface = MISSING (can be missing)
139-143 unsigned scaledValueOfSecondFixedSurface = MISSING (can be missing)

Now you can clearly see which keys are MISSING in this message and which ones can be set to MISSING.