How is magic used in "The Handsomest Drowned Man in the World" to encourage the villagers to change their lives?
Is your question referring to magic realism? This is the literary style that combines incredible events with realistic details and relates them all in a matter-of-fact tone. This style emerged from Latin America around the middle of the twentieth century and has gained world-wide popularity. Magic realism blurs the lines that usually separate what seems real from what seems imagined or fantastic.
There are certainly many elements of magic realism in the description of "Esteban", or the drowned man, which certainly serve to make him as a character have the massive impact he does on the village. These would include the massive size and beauty of the man. Note how the narrator describes him using magic realism:
Not only was he the tallest, strongest, most virile, and best-built man they had ever seen, but even though they were looking at him there was no room for him in their imagination.
The clearly mythical status that this man has, described using magic realism, therefore explains the way that the villagers feel strangely attracted to him, claim him for their own, and then are able to transform their lives because of the experience of having the man in their presence. It is this "magic" that perhaps you are referring to in your question.
The "magic" you refer to has to do with the fantasy elements of the story. The tremendous size of the corpse, his great beauty, the fact that the corpse apparently has travelled a long way in the sea before washing up on the beach of the village, the fact that the corpse has not decomposed at all after all that time in the water, and then additional days being prepared for disposal by the women—these things suggest that the corpse must mean something more than what it is. For the women in the village, the corpse represents a kind of ideal man, a standard of virility that their husbands cannot match. More than that, the corpse reinvigorates the village—as a result of Estaban's brief sojourn with them, the houses become bigger and stronger, more flowers grow, and the people take a greater pride in being from the village. Perhaps the most "magical" thing in the story is how something dead could confer such life on a place!