It really depends upon the Link in question.
In ALttP he probably did it for the good of his dearly departed Uncle who died trying to do the task Link was trying to do.
In LA, he did it simply because he had to do it in order to leave and get back to Hyrule.
In OoT, the same thing, doing...