"The Masque of the Red Death" by Edgar Allan Poe is a horror story set in Italy in the fourteenth century.
The main medical background to the story is the Black Death, a real plague that swept across Europe in the fourteenth century, causing the deaths of some 75 to 200 million people. The notion of an isolated group of nobles entertaining themselves in a castle may be derived from Boccaccio's Decameron, based on events of an outbreak of the Black Death in Florence.
The main element of the social background to the story is income and social inequality. While many poor people were trapped in the cities where infectious diseases could spread rapidly, Prince Prospero and his fellow aristocrats could isolate themselves in their country estates. In a sense, this is emblematic of many of the ways in which the very wealthy can insulate themselves from social problems of all sorts. However, a major point of the story is that death comes for everyone eventually, no matter what their social status.