Function of the supernatural (gods/goddesses)

What is the function of the supernatural (gods/goddesses) in both The Epic of Gilgamesh and The Iliad?