What was the purpose of the Vikings wearing horned helmets?

There's no evidence that the vikings ever wore horned helmets. For combat gear it'd be kinda silly to create a helmet that's real easy to knock off.

That image was most probably created by the movie industry.

Sticking something big and pointy on top of a helmet will make the wearer look taller, and probably more ferocious though, so it makes a great stage prop.