"Twilight of the Gods is related to the legend of Nibelungs"
It had nothing to do before Richard Wagner (1813 - 1883) to unite them in a series of operas. In Wagner, the gods need Nibelungs treasure, guarded by the dwarf Alberich, in order to offer of a giant, founder of their city in order to love goddess Freya ransom, initially promised as a reward. In the Edda, the gods are cruel and kills the giant. It is one of the sins you have to surrender at the end of the massive battles.