Currently watching a show about a Medieval European royal court and it's full of affairs, premarital sex, etc. But the general population during that period was very sexually conservative and the influence of religion was very strong. Why the dichotomy?
I would take the depictions in these shows with a grain of salt, but it is true that there were different moral norms and expectations around sexuality among different classes, which can in part be explained by the different functions that marriage had.
Among the lower classes, marriage was an economic as well as personal partnership, with spouses strongly relying on each other for survival and often living in close quarters. You can see how marital fidelity would be highly valued in this context and promiscuity as a threat to the stability of the family unit.
Medieval and early modern elites, on the other hand, married for strategic reasons, e.g. cement relations between families, diplomatic alliances, power brokerage etc. As a result, there was little expectation of love between the spouses and marital fidelity only mattered up until the point that an heir (and preferably a spare) had been produced. After that it was generally accepted that people had affairs on the side, as long as they were discrete about it.
When it comes to pre-marital sex, I would argue that commoners actually had more leeway than the ruling classes, or at least than elite women, because they had less to lose in terms of status and respectability. Virginity was policed most strongly when property and inheritance were issues of concern, to prevent the risk of an illegitimate child claiming wealth and titles.
Medieval populations were likely far less obsessed with chastity than is often depicted. The image we have today of strict sexual morals is more the product of the period that followed, after the Reformation and Catholic counter-reformation, when authorities became much more successful in disciplining people’s behavior and more formal laws around marriage and sexuality emerged.
Slightly later than the period you're asking about I suspect, but one famously 'liberal' court was that of Charles II of England. The king and his courtiers commonly kept several mistresses basically openly, and the court was also famed for liberal attitudes to things other than sex like music, dancing, drinking, comedy etc.
However, this was a widely known and commented on aspect of his court, subject to jokes and public discussion, which would suggest to me it wasn't particularly common, or at least, not in so open a way.
This is complicated, however, because in this case there was also a political purpose to this image, Charles was portrayed as 'the merry monarch' in contrast to the image of Cromwell's protectorate which preceded him as being dour, dark, and stern. And it worked pretty well, with Charles being broadly fairly popular and his enemies often successfully portrayed as religious fanatics in the vein of Cromwell. Unlike his father who preceded him or his brother who succeeded him, Charles was never overthrown and died naturally on how throne, and this image arguably contributed to that popularity. So it's possible that either the 'libertine' image of Charles's court was exaggerated for this effect, or it wasn't covered up in the way it might have been with other courts in the past.