"At his Majesty's pleasure" means that someone is being kept in prison for an undefined amount of time, until the King or Queen decides to release them. Imagine if you were playing a game of hide and seek, and your friend said you had to hide behind a curtain until they said you could come out. It's like that, except with jail and the person in charge is the King or Queen.
For example, if someone did something wrong and was sent to jail, but there wasn't a specific time they had to stay there, they would be there "at his Majesty's pleasure". This means that they could be in jail for a few months, years or even the rest of their life, depending on what the King or Queen decided.
Basically, it means that the person's release from jail is at the mercy of the ruler, and they could be in jail for a really long time without knowing when they will be let out.