For specificity's sake, let's say in Europe from the Medieval period up until the 19th & early 20th century. For the most part, at least to my understanding, women during this time were not allowed to become priests, serve in the military, own property independent of their husbands, vote, or attend universities, among other things. In general, society also held largely misogynistic attitudes towards women. So why were women still allowed to become the monarch, especially back when monarchies still held considerable power over the country?
The answer is complex, but boils down to continuing the line of the ruling family. But it also wasn't simple.
Take Maria Theresa, archduchess of Austria. The Habsburgians had provisions for daughters to inherit the realms should there be no sons; and this situation turned out to happen. This is quite typical - no male heir close to the departed king was available, so a daughter inherited - Maria Theresa's daughter, however, would not have usually inherited because earlier treaties meant her cousins - the daughters of her father's elder brother - would inherit first. Her father changed this in her favor. Effectively, in German-speaking areas, Lex Salica was in still effect which limited inheritance to men - but the Habsburgians changed this law with regard to their own domains.
Ruling for her was not simple nor easy. While the archduchy could go to her, the Roman Holy Empire (her father was emperor) could only be ruled by a man. Electors could only be men. Her husband himself was not an elector; she bended some rules to make him co-ruler of her lands so that he could be elected in her stead. Her not being able to succeed her father as emperor due to her gender made things difficult, her position was weakened and several wars followed, though ultimately, after the five year war of Austrian succession, she persisted and her husband was made emperor. Now, interestingly, her husband Francis was quite content to leave the ruling to her, and according to Karl Roider's biography of her, she even asked him to leave council meetings when they disagreed.
Now, Maria Theresia is an interesting early modern woman who actually wielded power. She did this through legitimacy - which becomes central in early modern times to a ruler's power - and was certainly well-educated. However, by this time, some monarchs did educate their daughters, especially the Habsburgs. There's evidence Maria Theresia spoke four languages, for example, and had extensive religious education.
You could also look at Elisabeth I. of England or Mary, Queen of Scots. The above-mentioned Salic Law of male succession didn't really exist on the British isles, and female inheritance if no male heir was available wasn't as novel.
Finally, one should point out that women weren't completely powerless in the medieval ages. Queen dowagers ruled as regents for their underage sons when their husbands passed, abesses ruled over considerable territories. Sometimes, female regents (such as Margaret I. of Denmark) were kinda ambivalent about their status, were often adressed as Queen, with ambivalence whether they were queen-regnant or queen-regent.
I just responded to a very similar question a couple of days ago, so I'll c/p what I wrote then below:
I have a few past answers on this topic that I'll link here with some choice quotes:
Were women monarchs as respected as their male counterparts?
Neither option is exactly the case: early modern female monarchs often had to deal with or work around gendered assumptions and stereotypes, but they unquestionably had the right to rule without being undermined or contradicted by the men around them. I think it would be fair to say that the misogyny in many cases came out more strongly once the female autocrat's reign was done and could be evaluated publicly (and blamed) by their successors and by male historians and commentators.
Did ruling Queens in historical Europe face gender discrimination?
The thing about sexism (and every -ism) is that it's like an iceberg: 90% of it is underwater. That is, most sexism doesn't come in the form of a man standing in front of a woman, saying, "You can't do this! This is for men only!" or blatantly sexually harassing her or believing that all men are inherently better than all women à la TRP - it's more subtle and ingrained. A lot of it comes from the assumptions people, even women, grow up with about what's seen as normal behavior.
Victoria would continue to use her gender to her advantage in constructing her image to the public. Where her distant predecessor Elizabeth I had made a show of entertaining suitors but ultimately held onto power by becoming the ever-youthful Virgin Queen, she married at 21; where Mary I had joined with the king of Spain to form a union with a lot of issues regarding a balance of power, Victoria chose a prince from one of the German states who couldn't challenge her. She and Albert then went on to have a slew of healthy babies, which allowed her to be portrayed as a wise and loving mother - a very appropriate and laudable role for a woman.
The main thing that I would draw your attention to for discussion is the idea that women were entirely discounted until the twentieth century. (Heck, pop culture would have it that women weren't considered people until the 1970s.) This isn't true, or at least is a misunderstanding. Women's capabilities were commonly minimized in historical European medical texts, but in terms of everyday life, they weren't considered a lower order of being. In aristocratic and royal circles, it was common for married women to act legally and managerially for their husbands when said husbands were away (which they were frequently). Noble widows acted as executors for their husbands wills, overseeing the transfer of huge tracts of land and large sums of money, and they defended their rights in court when needed, while dowager queens, particularly in the Early Modern period, could act as regent monarchs in their sons' minorities. Women gave patronage to religious houses - not a small show of power and influence in an era where religion played a major part in daily life and politics - and wielded considerable amounts of soft interpersonal power as well. The study of women's history from the 1990s forward shows that they had much more respect and agency than was previously believed, despite, of course, the severe institutional restrictions against their having official positions outside of their relationships to men.
Some books I would recommend on this topic:
Barbara J. Harris, English Aristocratic Women, 1450-1550: Marriage and Family, Property and Careers (2002)
Theresa Earenfight, Women and Wealth in Late Medieval Europe (2010) and Queenship in Medieval Europe (2013)
Queens Matter in Early Modern Studies (2018), edited by Anna Riehl Bertolet
Susan M. Johns, Noblewomen, Aristocracy and Power in the Twelfth-Century Anglo-Norman Realm (2003)
Gendering the Master Narrative: Women and Power in the Middle Ages (2003), edited by Mary C. Erler and Maryanne Kowaleski