The prince thought that if he isolated himself from the plague running rampart throughout the countryside, he would be able to avoid contamination. He invited a select few to be part of his court to keep him company. Also, in that way he could "play king" and pretend that everything was normal. However, the "out of sight, out of mind" principle did not work, as Death came to his very door.
Check out the reference below for further insight into the multiple meanings of the mask in this regard.
In Edgar Allan Poe's allegorical story "The Masque of the Red Death," the "Red Death" has swept through the country, devastating the population with a hideous and fatal pestilence. The epidemic causes "sharp pains, and sudden dizziness, and then profuse bleeding at the pores, with dissolution" all within the span of half an hour.
After half of the population is wiped out by this disease, Prince Prospero makes the selfish decision to sequester his personal friends (mostly knights, ladies, and other courtiers) within the castle in order to protect them from the Red Death. Beyond the iron gates of this stronghold, the commoners continue to suffer and die. This arrangement goes on for five or six months until Prospero decides to throw a masquerade and the embodiment of the Red Death arrives, spreading the disease to those who believed their wealth and social status could protect them.