I agree. But can we still judge human behavior based on our moral codes?
That is a very difficult question to answer.
Even extreme cases, such as man who rapes women, is doing what is in his best interest to spread his genes. If that male is not desirable to females, he has no choice to do that, or else his genes die out. It happens in animal world too. You can imagine a world in which males are very sexually passive, and do not aggressively mate. That could mean the extinction of the species. Of course, in no way am I condoning rape, but we are animals, and rape exists because it was a selected behaviour that allowed for genes to pass on. It could very well be that you owe your existence because some ancestor committed rape.
Same for adultery. In human society, cheating is immoral. But it can be beneficial to human fitness. A fit male benefits society by spreading his good genes to as many females as possible, creating a healthy variety of offspring with his good genes. If he mated with just one female, they offspring would not be genetically disverse, and there would also be fewer offspring. Similarly, a female who cheats also is not putting all her eggs in one basket, and is creating more chances for genetically diverse children which is healthy for human survival. This is why females will cheat with high quality males (tall, strong, rich (signifying their fitness and ability to secure resources and provide).
Same goes for murder. In prehistoric times, any kind of undesirable behavior that threatened the well being of society needed to be eliminated. For example, one violent individual who stole and terrorized the group needed to be killed. Those who were willing to kill because they felt their was injustice were actually doing the group a favor by eliminating a threat.
The reality is that morals change with times. It used to be that it was completely acceptable for men to marry girls as young as 12 in many societies. This was because people died a lot sooner, and it was important to breed early while the girls were fertile.
It turns out that usually what is moral is what is best for the survival of the human species and its well being. Say, for example that murder and rape were traits that allowed the human species to flourish, and not having those traits meant the extinction of humans. In that case, it may mean that humans would somehow modify their moral code to make those behaviours acceptable, if not commendable.
However, we know that a person who murders innocent victims who are beneficial to society are actually committing harm. And we know that a man who rapes women is spreading his genes without a woman's consent, thereby bypassing natural selection (survival of the fittest, as chosen by females) and therefore spreading possibly inferior genes, and again being harmful to the fitness of the human species.
Thus, murder is moral if it benefits society. For example executing a man who killed an innocent child. Or defending yourself from a violent person who was about kill you.