The origin of lutefisk is lost to the mists of time. One thing we know for certain is this:

Someone really really disliked the Vikings and tried to poison them.

The story goes thus:
The Vikings invaded Sweden/Ireland, which made the locals very upset. Either that, or someone, somewhere, somehow managed to capture some Vikings and held them prisoner (a likely story).

In any event, the locals, wanting to rid themselves of the noisome guests/prisoners/invaders, poisoned the dried cod stocks with lye. The nasty stuff was cooked and served up to the Vikings ...

... who ate it and liked it. Or at least it didn't kill them. Which for Scandinavian cuisine is much the same.

So there you have it, the story of lutefisk. I myself have never had the good fortune to eat of this lovely dish, but I am sure that it as ambrosia of the gods.