Firstly evolutioon has equipped us to take notice and reject those who try to freeload. Someone who is unwilling to assist others in the group will be noticed and tend not to receive help themselves.
Secondly, as societies have developed our view of who is in our "group" ("us") has tended to expand, to the point where some people consider all humans (and even hypothetical extra-terrestrial sapients) as part of their "group".
On the other hand just because some behaviour confers a selective advantage it does not mean that it is considered moral. Morality is those behaviours which aid the group over any direct benefit to the individual. Rape is not such a behaviour - it is genetically selfish. It is in the female's reproductive interest to choose a mate (and have a mate that will support her and her children - whcih a rapist is unlikely to do). It is in the interests of her relatives - male and female - that she should be able to do so (kin selection), in addiiton to any physical or emotional harm she may suffer as a result of the rape. Rape takes that away so it represents a conflict of interests - just as theft does. Selfish behaviour which hurts the group either directly or by creating conflict within it is contrary to those instincts which we call morality, and that is why we do not consider rape moral.