iirc the accepted theory for the development of eusocial insects specifically is: if you're all sisters, helping each other out DOES pass on your genes, even if you only share some of them. not hard to look at this and extend it to realize that community is a protective strategy as a whole!!