This is a lovely problem. Leaving aside the evidence this provides for the raw absurdity of the current D&D alignment system, I'll try to sort this out.
The first question we have to address is where the nature of a people or race comes from. Obviously, the nature-nurture debate can't be easily mapped back onto the D&D world. Genetics and psychology don't exist as fields in D&D worlds and even if they did, we know that in the case of genetics at least, it would be a wrong theory.
So, what are some viable theories that might be true in a D&D world?
1.
Environment: By this I don't mean social environment, I mean the theories of cultural difference that Greek and Roman philosophers and geographers subscribed to. The idea was that the physical locale a group lived in determined what kind of people they were -- in particular, humidity and heat were preponderant factors but there were other concerns as well. Not only did environmental conditions shape how societies worked and their values but individuals and group of a particular nature were thought to be attracted to an environment that suited them.
2.
Nobility: By this, I don't mean a strict theory of bloodline but rather a Tolkienesque idea -- a whole people is enobled if its leader does something great or courageous or if a group distinguishes itself in battle. Thus, a people may become more or less noble based on their leader's conduct or their collective conduct.
3.
Divine Inheritance: The fate of a people may be tied to the conduct and nature of their god -- when their god is good, they are good; when their god is powerful, they are powerful, etc. This may include both a lineal descent from the god and the ongoing relationship between the race and the god.
So, how do these things reflect on the question of how evil inheres in goblins?
First of all, there are game mechanical factors:
1.
Usually: Goblins have a "usually" alignment. According to the rules,
Monster Manual said:
The majority (more than 50%) of these creatures have the given alignment. This may be due to strong cultural influences, or it may be a legacy of the creatures' origin. For example, most elves inherited their chaotic good alignment from their creator, the deity Corellon Larethian.
2.
Detectability: Unlike most worlds, in the D&D world, it is very hard for either large groups or powerful individuals to be unaware of their goodness or evilness. Detection spells, aligned weapons and spells, etc. make it very difficult not to know one's own alignment.
There are also some sizeable game mechanical holes. In particular, D&D rules do not list the characteristics of creatures who are less than adult, except for dragons. So, it's difficult to discern how and if the creatures' mental attributes and alignment tend to change over time.
Anyway, I've rambled on for a bit and I actually need a break to think through how this information could bear on this issue. So, I'll post again shortly.