Most people have some code of honor. We might attend a school with an Honor Code, or take an oath serving in the military binding us to some standard. We might join any number of organisations that require we adopt not only a list of rules, but particular attitudes toward women, or fellow-members. More difficult to describe but just as powerful are informal codes, sometimes instilled in us from earliest years. Wodehouse did a send-up of this with the Code of the Woosters, with the insistence on the straight bat and not shooting a sitting bird by the upper classes, but they were (and still are) real enough to some of those gentlemen to shape or even dictate behavior. Many of these are not trivial.
There is a dark side. In prison the code is nearly reduced to one directive, not to snitch, and something similar held in the Mafia. Secret societies were mostly benign and even laudable - I recall reciting the line "worthy of the commendation of all good men" in many ceremonies. Yet even those had a climate of favoritism and elitism that excluded others by sex, by class, by race.
There is also the application of "honor" to ideas of mere status or even public perception of status. Men who were overproud of their rank - perhaps even their imagined rank - would "demand satisfaction" from another who they felt did not greet them with proper courtesy, and this did not mean common politeness, but an acknowledgement of rank and even superiority. The lines and shadings are not clear, but it reaches its worst in the street culture of gunplay over someone who was dissing me.
Still, despite its potential for abuse it is regarded as a general good thing. It is usually applied by good people not so much to hold others to our standards, but to hold ourselves to our own standards, as a Matter of Honor. It can become expensive, even unto death. A good man does not lightly toss aside what he has been taught since birth is worthy conduct.
The Gawaine poet intentionally sets up this contrast between honor and holiness as an impossible test for the hero. Sir Gawaine is repeatedly described as exceptional in courtesy, even best in Courtesy, which was the chivalric code and more. The good knight relies on his code in all his actions, up unto the full temptation scenes, and they serve him well. Religion, faith, holiness, these are present only by implication in the background. Play by the good rules and all will be well. Yet the Green Man (in disguise) and his Lady have engineered problem with no solution. Gawaine must either commit sin or offend against courtesy by breaking the rules of hospitality by a guest.
This was the poet's point, yet it is not set up as a flannelgraph tale. He could have made a simple didactic point that all human codes are inadequate and only righteousness can win in the end, yet chooses this story instead. Not only can you not do it, even Gawaine cannot accomplish it, and who are you compared to Gawaine? The conflict tears him in half, which itself echoes the imminent situation he faces, of having his head severed from his body. When the moment comes that he will receive the return stroke of the Green Man, he is already torn in half, and the lesson he learns by receiving mercy only partly restores him.