This is a woman who was desperate to study medicine in the very early 1800s, enrolled in 1809 - 60 years before the first female medical students were allowed into Edinburgh University, leading to riots, protests, attempts to sabotage them, they were overcharged, tutors refused to teach them etc.
Barry had died of old age just four years earlier and would have known all the way to the end that admitting to being female in a world where female doctors simply were not allowed, everything she had worked for would have been lost. All the respect, the esteem, the success would have been gone.
Of course she remained hidden. And she knew also from the few other cases like hers that had been uncovered to great fanfare in her time, that if she was found to be female after her death, her legacy would have been reduced to the same kind of idle speculation, her achievements ignored over the same notoriety she would have gained instead.
From the little I know, many of her compatriots had an inkling that she wasn't entirely or really male, but because she was indeed a brilliant, passionate doctor, most of them didn't seem to care - and since she never seems to have let anyone come too close (she certainly seems to have had no significant other), it may not have been that hard for those who knew her to just leave her be - especially since she had powerful patrons.
This transing of the dead, a full 150 years afterwards is ridiculous, given that there are plenty of documented cases of women doing the same - pretend to be men to be allowed out of the restrictive sphere of women.