I find many of the descriptions of gain and offset in this forum and in Cloudy Nights a little confusing. The software configures the hardware so I have analysed the hardware in an attempt to work out from first principles what the settings do for us and how it affects the quality of our image. I apologise for this being long, but there is a lot to describe.
Each time a photon hits the imaging chip there is a chance (the quantum efficiency) it will be captured and generate a free electron that will then become trapped in the insulated gate of the CMOS image cell (pixel). The pixel is one plate of a capacitor that is charging up one electron at a time as the light is received. When the image is read, the voltage on each gate is amplified via the programmable gain amplifier (PGA) that sits between the cell and the digitizer (analog to digital converter). The resulting voltage is converted to a 12 bit digital signal (our ADU’s).
Image cell (capacitor) -> PGA -> 12 bit Analog to Digital Converter -> the image
The voltage on a capacitor is proportional to the number of electrons and the size of the capacitor plate. In this chip the voltage generated by 20k electrons is the voltage Panasonic calibrated the internal reference voltage so that the digitiser output is a full reading of 4095 (65535 in SGP as it scales it). Since the PGA can be set to any value from 0 to 300 where each value corresponds to a 0.1dB step in the gain, we have 300 different gains available to us that correspond to a scaling of the voltage from 1 to 25.5 (you can set the Gain value to more that 300, but the chip itself is configured so that 300 is the highest value). So, if we are scaling up the voltage by 25.5, then full voltage out of the PGA is achieved with 1/25.5 of the voltage going into it from the image cell. This is the voltage that would be achieved by 20,000/25.5 = 785 electrons (you can see this on the graph published by ZWO). Similarly, a gain of 139 corresponds to a voltage gain of 5.002 and therefore full digital signal is achieved with a well containing 4,000 electrons. If we change the starting point from a nominally advertised 20k electrons to exactly 20,485 electrons it will generate enough voltage to give full signal after the amplifier with 20,485/5.002=4095 electrons. Huh!, this is exactly 1 electron per digital count (ADU) just like they advertise.
If we set the gain to 85 then 8185 electrons are needed to read a full 12-bit signal of 4095. Every second electron makes no change to the signal we read (quantisation error or noise), but we can see a greater range of brightness because we can see from dark to twice as many photons and everything in between. Put another way, the noise has gone up because of the steps in signal and sometimes no step when we have more signal, but the dynamic range is greater because we can collect more electrons before we saturate the digitiser. Low brightness regions will have fewer steps in the brightness, so a stretched image could look banded rather than a smooth graduation in intensity, but the bright stars will look great.
If we set the gain to 215 then 2034 electrons will lead to a full 12-bit signal. This means that every half electron will lead to one more bit increase in the reading. It sounds great, but we can’t have half an electron, so the digitised signal is going to step up two counts each time an extra electron is captured by the sensor. This will show up as increased noise and lower dynamic range. We could have done this by stretching the resulting image.
In summary, any gain greater than 139 will lead you to a risk that the lower dynamic range will limit the quality of your image. A gain of less than 139 will give you higher quantisation noise, but the benefit of higher dynamic range, stars that aren’t blown, but any weak nebulous regions will have fewer steps in brightness available. In my opinion the electronics is geared up so that 139 is the correct setting and the only time it is worth using a different value is when you must have a higher dynamic range for an object without nebulosity, such as with a globular cluster. The Offset is an outcome of the amplifier gain on internal leakage currents that offset the voltage, so we should follow the manufacturers recommended value to do what they have measured is needed.
Please note that this is an analysis of the electronics, not of astrophotography. The electronics is easier.