To understand the function of this uninvited and unwanted guest at the masquerade ball you need to appreciate the way that symbolism operates throughout this entire short story. Poe is a master of symbolism, and it is clear if you study the text carefully, that this masked visitor represents death himself, as suggested through the disease of the Red Death that eventually plagues Prospero's hideout. Consider how the guest is presented:
The figure was tall and gaunt, and shrouded from head to foot in the habiliments of the grave. The mask which concealed the visage was made so nearly to resemble the countenance of a stiffened corpsoe that the closest scrutiny must have had difficulty in detecting the cheat. And yet all this might have been endured, if not approved, by the mad revelers around. But the mummer had gone so far as to assume the type of the Red Death. His vesture was dabbled in blood--and his broad brow, with all the features of the face, was besprinkled with teh scarlet horror.
Not only does this figure resemble the Red Death, he also symbolically turns to confront Propsero in the seventh, black room, which also is the room on the extreme west. The rooms are coloured symbolically, with this room, with its dark colour and the clock, symbolising death and the setting of the sun and the mortality of man. Thus it is entirely fitting that the Mummer reveals himself in this room and the Red Death descends on the guests. Death will not be cheated and cannot be escaped--as Prospero learns the hard way.