This is a good question, especially in view of the fact that Eumaios is a faithful friend.
If you recall, Odysseus was away from home for a long time. Not only did he fight in the Trojan War, but he also had a hard time getting home! For this reason when he returned, he did not know who was faithful to him. Times change as do people. So, he wanted to disguise himself.
In addition, Odysseus comes back in a much weaker position. For this reason the element of surprise was something that he needed to work to his advantage.
Loyalty is a huge theme in the Odyssey. People who are loyal vs. disloyal are emphasized over and over again. Eumaios, the swineherd of Ithaca, has remained extremely loyal to his king Odysseus all these years. In fact, he is so loyal that he is referred to numerous times as "loyal Eumaios."
But of course, Odysseus doesn't know this quite yet when he first arrives back at Ithaca. Eumaios is the first person he encounters back home. He disguises himself in order to ask Eumaios lots of questions about the state of Ithaca and the well-being of his wife Penelope and his won Telemachus. Eumaios' answers, and his fond stories of his beloved king, tell Odysseus the truth. He finds out what is happening with the suitors in the palace, and he is shown that Eumaios is truly trustworthy.
Throughout his journey, Odysseus has become a more conscientious and careful person. He was always clever, but he used to also be arrogant and hotheaded. Before, he would rush into any situation head-on. However, he has grown more wise and thus is more careful with trusting people. He becomes more like his circumspect wife, Penelope, who is very wary.
Also, it is important to note that Odysseus is naturally a very tricky person. He is often is disguise, just to test out his own cleverness. There is even a point in the Odyssey in which he tries to trick Athena into thinking he is someone else! So it is probably also his natural inclination to approach people in disguise.