Invited paper: who has to be the first author? My supervisor received an invitation to submit a paper to a special issue of a prestigious journal. Naturally, I have done most of the writing (80%) and all the results in the manuscript are my work.

In this case, who has to be the first author? Is it him, for he is the one invited to submit the paper? Or is it me for doing most of the work?
If a person receives an invitation, the responsibility to deliver will be with that person. That does not necessarily mean that person will be first author although I suspect it will most frequently be the case. There are many posts on academia.se that deal with first authorships so I do not think I need to replicate many good answers here. Suffice it to say that you need to discuss the authorship with your advisor. Unfortunately, this should have been done early on because lack of an agreement on authorship ordering early on is what usually leads to conflicts in the end. I am not saying this applies in your case but the fact that you ask seems to go in that direction. 

For authorship and contributorship discussions I can point you to two posts in Council of Science Editors and BMJ (formerly the British Medical Journal). There are many other sources but they provide the core ideas on author/contributorship. It is easy to agree with these ideas, more difficult to live by them, particularly in a student-advisor relationship.