Answering exactly what you asked: Use double quotes instead....
Using single quotes, the sed receives the string '$i', not the expansion of $i which is 2,4,6...
Double quotes allow that expansion.
...but this will not solve your homework. try your script now and you will see the result.