Can I hand in an essay which I have written last year, but not as part of a course?
Could I just hand in this essay, or would I violate some rules with
  that?


If you wrote it as a personal exercise and it was never submitted to any course (i.e. never read), I can't see how anyone would notice the difference - provided you are right about the fact that it answers your assignment perfectly and you are not subconciously trying to make it fit into the assignment.


  Should I just hand in this essay?


Aside from the rules, consider the teaching value of writing an essay (which you obviously already know, since you wrote one as a personal exercise!).
If your workload allows it, you might find that re-working on that essay a year later is really instructive. Your perspective (on the content, but also on the writing level) probably changed in one year, and with the head-start of having a first version already, you could dig deeper into the subject and end up really learning a lot and producing an essay worth an amazing grade. Or, if you don't feel like reworking this one, maybe you could pick another subject altogether? The teaching goal of essays is usually to have you research a new subject; handing in your already written one, while being legal, would certainly not serve that purpose.