In the first, he did go, but there was no necessity for him to have done so.
In the second, it's not clear if he did go or not, but either way, it wan't necessary.
He went to.... He needn't have. It was a wasted trip.
He got home earlier than he had planned because it turned out that the didn't need to go to...
Although he went to..., he didn't need to.
Student or Learner