Why is it important for Gilgamesh and Enkidu to kill Humbaba in The Epic of Gilgamesh?
Gilgamesh, befitting his epic hero status, wants to fight and kill Humbaba to prove to his people that they should not be afraid of Humbaba and that the gods are able to be defied by mere mortals. Also, perhaps as a secondary motive, he wants to be able to inspire the youth of Uruk with his mighty deeds to encourage them to be great and powerful in the same way that he is. Note what he says in the following quote:
I want to prove
Him not the awesome thing we think he is
And that the boundaries set up by gods
Are not unbreakable. I will defeat him
In his cedar forest. The youth of Uruk
Need this fight. They have grown soft and restless.
Gilgamesh therefore openly states that part of his reason for wanting to fight Humbaba is to confront the fear that his people have of him as an "awesome thing" and also to challenge the gods in setting up their boundaries, which mortals think are "unbreakable." Of course, these motives, with their arrogance and hubris and defiance, are completely fitting for an epic hero who is determined to make a name for himself by doing what others do not because they are too afraid.
In the second tablet, Enkidu expresses to Gilgamesh that he has grown tired and weak from being idle. Gilgamesh responds by telling Enkidu that he has not established his name and stamped it on the bricks as his destiny decreed. He then decides that he and Enkidu will travel to the Forest of Cedar and defeat the evil Humbaba. However, Enkidu warns him about the dangers of entering the forest that Enlil has appointed Humbaba to guard. Gilgamesh then replies by saying,
"Where is the man who can clamber to heaven? Only the gods live forever with glorious Shamash, but as for us men, our days are numbered, our occupations are a breath of wind." (N. K. Sandars, 7)
Essentially, Gilgamesh believes that it is important to defeat the mighty Humbaba in order to cement his legacy for all mankind to witness and acknowledge. Gilgamesh is a prideful king, who is concerned about his legacy and wants his name to go down in history. Gilgamesh knows that by defeating Humbaba, his name will be written on the bricks of the wall surrounding Uruk. He also wants to show the citizens of Uruk that it is possible for humans to defy the gods.
Your question implies that it was necessary for the two heroes to kill Humbaba, but this is not the case. The Elders of Uruk and Enkidu both try to persuade Gilgamesh not to fight the monster. His own mother, the Goddess Ninsun, is unhappy about the expedition. She asks the sun god Shamash:
Why have you imposed a restless heart on my son Gilgamesh?
Now you have touched him so that he wants to travel a long way to where Humbaba is.
He will face fighting such as he has not known
He will travel on a road that he does not know
Although there is a suggestion in the text that the people will rejoice if Humbaba is killed and that he is hated by Shamash, the underlying message is that this adventure is foolhardy. This is not just because of the dangers involved, but because Humbaba is the official guardian of the cedar forrest, appointed by Enlil himself. Gilgamesh and Enkidu know that killing Humbaba will anger the gods. Enkidu says:
[Kill Humbaba] before the preeminent God Enlil hears... and the gods... be filled with rage against us
Consequently, when the council of the gods decide that either Gilgamesh or Enkidu must die, the reason is that:
...they killed the Bull of Heaven and have also slain Humbaba
So the slaughter of Humbaba was by no means "necessary". In fact, it was a foolish quest that lead directly to Enkidu's death. It was caused by Gilgamesh's selfish desire to "make a name" for himself. Only at the end of the story, after all of his attempts at securing immortality prove futile, does Gilgamesh realise that it is better to preserve life (like the flood hero) than to destroy it.