what do they hope to achieve by being there
By being "there" I think you mean behind the castle walls?? The "Red Death" was an epidemic. Some believe that it is a fictional disease, but Time magazine called smallpox "the Red Death". (See link below). Smallpox, however, does not have the symptoms explained in the first paragraph of the story.
"There were sharp pains, and sudden dizziness, and then profuse bleeding at the pores, with dissolution. The scarlet stains upon the body and especially upon the face of the victim... "
although it does cause a rash in the mouth and throat before moving all over the body. An epidemic affects many people in a specific area at the same time. It is spread through contact and being around people with the disease.
Prince Prospero was unconcerned about his people, but he and his friends wanted to avoid getting the disease. They want to avoid contact of any kind with those people who are suffering from it. So he
" summoned to his presence a thousand hale and light-hearted friends from among the knights and dames of his court"
He had built his castle into a strong fortress and had the servents weld bolts into the iron gate so that no one could enter or leave. They did not want to have any contact with those infected nor did they want to see them. Notice he invited his " hale and lighthearted" friends. "Hale" meaning that they had to be healthy, and "lighthearted" meaning that they enjoyed a good time. He still wanted to enjoy life, while his people were dying outside the castle gates. That is the reason he threw the masquerade ball. They had been confined for almost six months and the epidemic was at its height. So what they hoped to achieve was escape from the "Red Death"