Contrary to popular belief, e.g. and i.e. aren't interchangeable, and they mean different things. The easiest way to remember when to use i.e. vs e.g. is to listen how it would make your phrase sound if you substituted them with their true meaning.
i.e. stands for id est from latin, which really means "in other words," or "it/that is." It is followed by a specific description of what has been said.
e.g. stands for exempli gratia, often misinterpreted to mean example given. Translating it more accurately, gives us something like "for the sake of example" and It is usually followed by one of many available examples to elaborate on what has been said.
There's a much better and technical explanation here and here, that expand by giving you some examples.