First, let's do greed. Greed is an appetite uncontrolled. Consider, for example, a dog. If he sees food he simply moves directly towards the food and tries to eat it without any other concern or hesitation. He does not consider his co-dogs in the pack. Or his offspring. Nor even whether he is in fact hungry. He just tries to eat the food. This is greed.
Greed may be a survival trait in some circumstances. For example, in the wild in situations where food is scarce, uneaten food is wasted food.
Greed is usually counter productive for intelligent species, since it is deeply sub-optimal when you have the ability to produce enough of what you need. If you simply eat everything in your fridge you won't be healthy. 376
So greed might be a problem for intelligent critters that had it as a survival trait in the past, and now have to deal with things like diets. We resemble that. They might take steps to suppress it, remove it, overcome it, etc.
Selfishness means doing what is good for "self." However, in evolutionary terms, the thing that evolves is the gene. If an action tends to help spread one's genes around, but is bad for the individual, it may still get fixed in through evolution. A mother cat fighting to protect her kittens may get mauled by a dog but leave an extra batch of kittens. Her personal selfishness, running from the dog, and her gene's selfishness may conflict.
Somewhere though, the gene's selfishness must have at least a modicum of success, or the creature cannot procreate long enough to evolve.
For example, an intelligent creature that was evolved from a social insect might be ideally communal, except possibly for the "royal" breeder class. The workers and drones might be prepared to nearly-mindlessly sacrifice themselves for the good of the colony.
At some point in there, there has to be something that produces conditions that tend to advance its own interest. This is "selfish gene" theory, along the lines of the book The Selfish Gene by <PERSON>. This is a metaphor indicating the genes act as though they were selfish. Because if they don't they get out competed by genes that do.
So individuals may have their selfishness suppressed. But some part of the creature must act selfishly in some sense for the species to continue to exist. 376