Both abbreviations are actually for Latin, not English words.
Id est (i.e.) is Latin for “that is.”
Exempli gratia (e.g.) is the Latin “for example.”
If the phrase that follows means to further clarify or explain by means of definition, i.e. is more appropriate. If an example is given rather than a definition, then e.g. is correct.
These terms have been incorporated into the English language. Thus, there’s no need to italicize them. Also, commas precede and follow the expressions.
The following trick will help you remember the distinctions:
i.e. means in essence e.g. means example given Example: There are many great racehorses, e.g., Secretariat, Seattle Slew, but only a few like the ones I usually bet on, i.e., really slow.