Latin abbreviations are increasingly rare in today's scientific writing: the Council of Science Editors recommends and others instead of et al. and such abbreviations as op. cit. and loc. cit., commonly used in citing sources, are seldom seen now.
However, the use of e.g. is not all that rare; sometimes, it is incorrectly interchanged for i.e., and this blog post shows how the two are different and how they relate to another abbreviation, viz., which simply means namely.
What the three have in common is that all serve to elaborate the word or words that come before; where they differ relates to the nature of that elaboration, that is whether the elaboration consists of examples, rephrasing, or a list, as shown below.
Consider the sentence “A number of weather variables were recorded, e.g. precipitation, temperature, and relative humidity.” The abbreviation e.g. stands for Latin exempli gratia, which means for example. In the previous sentence, the term “variables” is explained by giving examples of some variables that were recorded. Used thus, the abbreviation implies that precipitation, temperature, and relative humidity were not the only variables recorded; perhaps evaporation, the number of sunshine hours, and the intensity of radiation were also recorded.
If the term precipitation needs to be explained, the author can write “Data on precipitation, i.e. rainfall and snowfall, were collected from local weather offices.” The abbreviation i.e. stands for Latin id est, which means in other words and separates two versions which mean the same, the first version being typically more compact.
Lastly, if all members of a group are to be named - an exhaustive list and not merely an illustrative one - namely, or its Latin form viz. is the correct choice. For example, consider the sentence “The present paper evaluates the effect of major weather variables, namely precipitation, temperature, and relative humidity, on crop growth.” Namely makes it clear that the paper is about the evaluation of only three weather variables, and not about any others such as evaporation and the number of sunshine hours.
Other similar words that are often confused are "including" and "such has." Read here to understand their usage better.
Related Reading -
The complete guide to writing a brilliant research paper