"I have held that, because of the constitutional position of the Sovereign, it is appropriate to have a special practice in relation to royal wills," McFarlane said in a written judgment. "There is a need to enhance the protection afforded to truly private aspects of the lives of this limited group of individuals in order to maintain the dignity of the Sovereign and close members of her family."
The judge stressed that he had not seen or been told of the contents of the will.
McFarlane said that as president of the High Court's family division, he is custodian of a safe which holds 30 envelopes, each containing the sealed will of a deceased royal, including the late Queen Mother Elizabeth and the current queen's sister, Princess Margaret. Both died in 2002.
In the years that followed, a man who claimed to be Margaret's illegitimate son, Robert Brown, fought a failed court battle to have both wills unsealed in order to seek evidence for his claim.
The judge said that while there might be "public curiosity" about royal wills, "there is no true public interest in the public knowing this wholly private information."
The ruling came after a court hearing in July that was held in private. Media organisations were not allowed to make the case for publishing the will.