These two abbreviations are often used interchangeably or confused for one another. However, while they both come from Latin phrases, they actually have completely different meanings.
E.g. comes from the phrase “exemplo gratia,” meaning “for example.” Only use this phrase where it would make sense to replace it with “for example.” For example (haha), “Hannah is a prolific artist, but she only paints scenery, e.g., beaches and forests.” In this sentence, beaches and forests are an example. Maybe Hannah also paints city skylines and mountains; the speaker in the sentence is not trying to give a complete list.
I.e. comes from the Latin phrase “id est,” which means “that is.” Only use it when you are drawing a direct relationship between the preceding clause and the following one. For example, “Sam works in information technology – i.e. he fixes computers.”