These two are abbreviations of Latin words.
e.g. stands for exempli gratia, which means for example.
Use e.g. when you want to list one or more examples of something you have mentioned.
Our products are sold in several European countries, e.g. France, Germany, Italy and Greece.
Since you want to give examples, don’t write a complete list.
i.e. stands for id est, which is Latin for that is or in other words.
Use i.e. to clarify or explain something.
I am a linguist, i.e. I study languages.
In writing, e.g. and i.e. are lowercase. There should be a full stop after each letter, and the abbreviations should be preceded by a comma. In American English there should also be a comma after the abbreviation; British English usually does not have this comma. Instead of a comma before the abbreviation you can have a dash.
Latin words are often italicized in English texts, but when abbreviated they should be written in normal font.
The two abbreviations can, of course, be written out in full: for example and that is or that is to say. You should avoid beginning a sentence with an abbreviation.
To sum up, e.g. opens up some possibilities, i.e. narrows them down.
You will find more Latin abbreviations in English here.