Would it be possible for a bastard son of a courtier or a peasant to inherite the throne?
I mean . . . yes, if no one discovered it, which is pretty unlikely. Medieval households were large, and modern notions of privacy didn't really exist. A monarch or his wife was surrounded by dozens if not hundreds of people at almost all times bar sleeping: relatives, ministers, household knights and sergeants, courtiers, servants, et al. Any time they left their residence, they would almost invariably be accompanied by a number of attendants. Our queen would have to either sneak someone into her bedroom, past numerous servants and other members of the court, without him being spotted (very unlikely); or she would have to hope that all of her attendants kept their mouths shut (unlikely); or she would have to sneak out of the castle or palace unobserved, or with the connivance of numerous people (just as unlikely).
We know a lot more about kings' bastards because they were out in the open. People generally knew who the king's mistresses were, and when one popped out a baby, it didn't take much guessing to figure out whose it was. Kings often acknowledged their bastards, and a goodly number became powerful noblemen in their own right - though they could not inherit the throne. William the Bastard of Normandy is an exception, because his father legitimized him and declared him his heir in public, and even that resulted in a bitter civil war between William and some of his cousins.