The short answer, basically, that ballet ceased being a practice linked with political power, and started being associated with qualities considered “feminine”. To develop a little bit (working in part with Marquié’s *Non, la danse n’est pas un truc de filles ! Essai sur le genre en danse*, which is on that exact matter, but not translated into English) :
So, as you note in your question, for a long time ballet, especially court ballets, were strongly associated with men. This in due, in part, to the role dance played in reconfiguring the role of noble and courtiers during the Renaissance, from a feudal/warring class to a more civil one. Court ballet were strongly associated with such notions as order, and linked to the practice of power ; learning to dance was among the core principals of a gentleman’s education. Women’s participation in court ballet was, at most, occasional.
The first shift occurred during the XVIIIth century, with the professionalization of ballet dancers and the creation of the “ballet d’action”. Dance was then less associated with (male) nobility, it was also less and less well-considered as an art form (because of its strong association with the body), and professional dancing troups, such as the one at the Paris Opéra, were equally masculine and feminine. That said, men still took centre stage and had a much more predominant role in ballet.
The second shift happened in the 1830s, in France, with the creation of the romantic ballet. First, one of the main elements of the new style was a strong differentiation between masculine and feminine style of dance, with the introduction of point work, which was specifically a feminine technique. The apparition of the “tutu”, a much lighter costume for women, also allowed them strong technical advances. That differentiation meant that each sexes now had a specific technique, and the female one would rise to prominence while the male one would be relegated in the background.
Second, this sexual differentiation was strongly aligned with bourgeois values that were taking center stage after the French revolution. According to their vision of gender (strongly influential on the romantic movement as a whole), the man was the one who had to deal with the corruption of the world, while his wife, a symbol of domestic purity, was his connection to God, to an otherworldly plane. This ideology of gender had a strong influence on artistic tastes, and successful ballets often reproduced it. What’s more, the “ballet d’action” of the XVIIIth century was progressively associated with the Ancient Régime and thus, strongly fell out of favor : a new style of dance was called for.
That’s why, beginning in the 1830s, ballet became a form predicated on binary oppositions, more often than not aligned with the opposition of masculine/feminine gender roles. For example, the opposition between the “ballet blanc”, situated in a fantastic world of ethereal beauty, and the acts situated in the real world. Moreover ballet, as a whole, was more and more associated with what was considered “feminine” traits : most notably, it was to stay far away from any realism, considered an enchanted and pure form, far from the reality of the mundane. Ballet is the reign of beauty ; beauty was a “feminine” quality ; therefore ballet became a feminine form. Ballet was also more and more conceptualized in terms of the emotions and sensations it produced, and less and less as a rational and orderly form : again, emotions are often considered “feminine”.
With that shift, male dancers were more and more an object of ridicule and contempt : they were engaging in a feminine activity ! Théophile Gautier, for example, writes that a male dancer is “something indecent and monstrous” : a man could be strong, he should not be graceful and beautiful. Here, we see how the new values associated with dance (grace and beauty rather than order and strength) became strongly associated with femininity. As a consequence, men’s roles in the ballet became less and less important – most of the dancing was done by women – and the social position of male dancer became less and less enviable.