The Red Death is very similar to the Black Death that wiped out a good portion of the European population in the 1300s. In this story, the theme or message is that there is no hiding from the Red Death—or any death. Death comes for us all and is the great leveler.
The privileged guests, lords and ladies, within the castle wall believe they can keep death out by shutting the doors against it. The castle that Prospero designs is meant to exclude the Red Death:
A strong and lofty wall girdled it in. This wall had gates of iron. The courtiers, having entered, brought furnaces and massy hammers and welded the bolts.
The guests also try to blot out the thought of death by being amply provisioned with food and drink and by partying, dancing, and entertainment:
There were buffoons, there were improvisatori, there were ballet-dancers, there were musicians, there was Beauty, there was wine. All these and security were within. Without was the "Red Death."
Only the ebony clock that tolls the hour loudly, putting a temporary stop to the music and festivities, reminds the guests of their mortality.
Yet, as we might expect, there is no locking out or blotting out death. By the end of the story it has invaded the castle despite the best efforts to keep it out:
And now was acknowledged the presence of the Red Death. He had come like a thief in the night. And one by one dropped the revellers in the blood-bedewed halls of their revel, and died each in the despairing posture of his fall.