Gain of an antenna is related to its directivity. Directivity is a numerical indication of the ability of an antenna to focus energy in a particular direction rather than spreading energy out uniformly over a wide angle range.
An antenna is not a lossless system, and some energy entering the antenna terminals is lost due to heat losses, etc. The gain of an antenna is its directivity reduced by the loss introduced by the antenna. The parameter that characterizes the loss of the antenna is called the radiation efficiency er, which has a value between 0 and 1.
It is to be noted that the loss mentioned here is not the mismatch loss, which is the loss occurring between an antenna and the feed transmission line connecting to it. The loss characterized by the radiation efficiency is strictly one that takes place in the antenna on a stand-alone basis, irrespective of the way it matches to the feed line.
For more information on these important topics, in addition to an explanation of the units of gain, please click here.