I don’t think we do judge people based on penmanship any more. You almost never see anyone’s handwriting any more.
I think that, on average (i.e., gross generalization), women are better at attending to details, and that includes the details of handwriting. Men are more impatient, and can’t be bothered to write clearly. They just want to get it done.
Obviously there’s a wide amount of variation, and I’m just making up those generalizations off the top of my head, but I think they might hold up.
Anyone can learn to write with clean lines and a steady hand if they spend time practicing. So in the days when secretarial work was man’s work, they learned how to write well. Also, I think that the student body was largely male. For a long time, women weren’t taught to write, except if they came from very wealthy families.
FWIW, I always hated writing. My hand would cramp rapidly. Learning to type saved my life, because I could finally go fast enough that I didn’t lose half my thoughts before they got put down on paper. For at least a decade I haven’t used a pen for much besides signing things. My signature has grown progressively less legible. Now, due to the influence of certain meds, my hands shake. Not only can I no longer hold chop sticks, but my illegible signature now looks like a spidery illegible signature.