In Odyssey 17, the title character has returned to his native land of Ithaca. Odysseus has been away from home for twenty years and his house has become overrun with 108 suitors, who are trying to get his wife Penelope to marry one of them. Because of this infestation by the suitors, Odysseus decides that it would be prudent to return to his house in disguise. Thus, goddess Athene helps transform him into a beggar.
In Odyssey 17, the disguised Odysseus goes around to the various suitors and begs for scraps of food. The reason Odysseus does this is because he is planning to kill the suitors and he wants to test them to see if any are hospitable toward him (hospitality, or xenia, is a major theme in this epic poem). Homer tells his audience that goddess Athene prompted Odysseus to do this:
Now Athene appeared at Odysseus’ side, close to that son of Laertes, and prompted him to go and gather scraps among the Suitors, and find out which were decent men and which were wild, not that she meant to save a single one from death. (A.S. Kline translation)
Later in the epic, in Book 22, we learn that Odysseus does not spare any of the suitors from death. Indeed, in Book 17, Antinous eventually hits Odysseus on the shoulder with a stool after Odysseus tries to beg some food from Antinous.
It also shows the audience of the Odyssey that all of the suitors are terrible people--uncompassionate and cruel. So when Odysseus kills all of them at the end, no one would feel sympathy towards the suitors. The scene in which Odysseus begs for scraps while disguised as a beggar is kind of "proof" that the suitors deserved to be killed violently.