Every emotion must had a reason when it was evolved into existence and genetically. Why did animals/humans started showing kindness to the other 'kind', when there was nothing they can gain by feeling 'kind'ness with other individual.
Evolution works at the species level, not at the individual level. Altruism evolved because it gave certain groups advantages aver other groups competing for the same resources. If an individual sacrifices their own personal needs for the group so that the group as whole thrives, the end result is still the propagation of that individual's genetic information (as a subset of the group genetic information), and evolution is driven by genes.
An extreme example of this are female worker ants and worker bees: These individuals do not mate at all, only the queens in their colonies/hives do, and yet they spend their whole lives dedicated to the well being of the group.
See the SEP article on altruism for further information.
Keep in mind that genes are causally related to phenomena occurring in many levels at the same time: molecular, cellular, systemic, individual, social, even environmental. The interplay of all these different levels is not without attrition. More often than not, the existence of a particular trait cannot be reduced to a single explanatory principle.
Your premise - that there's nothing to be gained from positive affections on the individual level - is probably unwarranted in itself, but also suffers from a limitation in perspective, as the best utilitarian explanations for the existence of emotions are probably those that investigate the phenomenon at the social level.