He might have known (and even the extent of this is not clear) that what he was doing was illegal.
But that doesn't mean it is wrong, law and morality are two very different things.
Me and many others would argue that what he did was almost a moral imperative, he tried to free human knowledge (mostly paid by tax dollars!) from the artificial monopoly of some corporate leeches.
And if you need more arguments for this, just read up on what Thomas Jefferson had to say about it: http://harmful.cat-v.org/economics/intellectual_property/