Why εγώ at the end of this sentence?
I'm fairly certain it's just for emphasis; grammatically, it doesn't need to be there.
Correct! In Greek this essentially means 'It wasn't me!'
Could this have been written: Εγω δεν το ειχα κανει. ?
Yes. You can say it too. It means the same
I had not done it. - was not accepted like correct
"εγώ" is not necessary to say "I had not done it." ; it is a kind of emphasis, specially at the end of the sentence. So, can't we translate this emphasis by adding "myself" in English ? "I had not done it myself" : refused by Duo.