The answer to this question partially depends on what translation a student is reading. One of the problems with understanding Gilgamesh is that the tablets on which it was originally inscribed were already damaged and very hard to decipher when that modern translation process began. Thus, various translators have drawn from other flood narratives to elaborate on the story. What has been translated, though, leads to the understanding that the gods were dissatisfied by and angry with the humans--much like in other flood narratives. In various translations, the god that is portrayed as most angry and the leader in this plan of destruction is Enlil.
In addition to the gods' motivation of anger and dissatisfaction, Utnapishtim lets Gilgamesh know that there is not supposed to be permanence in the mortal world; thus, destroying mankind is actually part of the greater plan. He also suggests that the gods are capricious and do not always act in ways that mortals can understand.
The civilization represented in the story is polytheistic, and several of the gods are sworn to secrecy about their plan to destroy mankind. For whatever reason, though, the god Ea relents slightly and communicates to Utnapishtim that he needs to build a boat so that he can save his family. After the flood waters recede, Enlil is angry that Utnapishtim and his family have survived, but after being chastised for not seeking the help and counsel of the god Ea (the god of earth and water), Enlil eventually sees the error of his earlier thinking.
Overall, Utnapishtim communicates to Gilgamesh that the gods do what the gods want to do. Whether it is anger or capriciousness that is the primary motivation depends more on the translation being used.