Natural selection happens at the gene level. A behavior has to beneficial to the gene or genes that cause it for it to propagate via natural selection. It’s hard to model homosexuality as anything other than detrimental to the gene or genes that contribute to it. The only model that accounts for this would be if homosexuality is an occasional side effect of some other traits or behaviors that increase fertility.