i.e. comes from Latin ‘id est’ which means ‘that is to say’. It should be used to give further clarification of your point or to say the same point in simpler or alternative words, as in ‘the weather is beautiful today, i.e. not raining’.
e.g. is also from Latin and means ‘exempli gratia’, meaning ‘for example’. As suggested, it is used to add examples to your point and not clarify it, as in ‘you can buy all kinds of products in a supermarket, e.g. fruit, meat and eggs’.
Both should you be written in the lower case with a full stop between and after each letter, with no spaces and not italicised.