The Happy Prince is a statue and so is unable to move. Nonetheless, from his position high up on a pedestal, he's still able to witness scenes of extreme poverty and suffering. When the prince was alive, he never knew about any of this; he lived a happy life of ease and luxury in the royal palace. But now, with his spirit embodied in the statue, he's truly shocked and horrified at what goes on in the city he never really knew when he was alive. The prince wants to make amends; he wants to help alleviate some of the social evils of the world down below.
As a little bird, the swallow is able to fly all over the city. This gives him the opportunity to see more of urban life, giving him a greater knowledge of the city than the prince has ever had or ever will have. He's ideally placed to respond to the prince's request and take valuable objects from his statue and dispense them to the city's poor and needy. The Happy Prince becomes even more reliant on the swallow after the little bird removes the sapphires from his eyes, because then the prince cannot see and so must depend on the bird for knowledge of the city beneath his statue.