Your theory is flawed. Two people growing up in the same environment don't necessarily have the same sexual orientation. But identical twins have a higher incidents of both having the same orientation than fraternal twins and other siblings.
As people grow up, there are things they learn about themselves. They learn which hand they should write with, depending on the hand-dominance present from birth. And they learn whether they are naturally attracted to the opposite sex, the same sex, or both. The only choice any of us has is whether to act on the natural attraction, or to hide it and attempt to live a lie to make homophobic people comfortable/happy.
You don't see what purpose homosexuality fulfills because you have never looked for it. While the answer is harder to see in humans, because our own "better way" often interferes with nature, it is easily seen in the rest of nature. Almost every species that reproduces by sexual means has individuals that are exclusively homosexual, and usually individuals who are bisexual. Same-sex pairs in nature exhibit the same behavior as opposite-sex pairs: pair bonding, affection, sexual activity, etc. Among species that mate for life, same-sex pairs are common, and will often adopt orphaned young.
Homosexuality is nature's built-in way of preventing overpopulation. When a steady percentage of a species does not reproduce by nature, there is far less chance of running out of resource due to excessive numbers. Further, the willingness of same-sex pairs to adopt orphaned young helps to preserve the species.
All of this is well-documented and published. And it carries far more weight than the ignorant claims of some that any homosexuality among animals is about dominance or lack of the opposite sex. The evidence simply cannot support such claims.
So homosexuality is a normal variant of human sexuality, and serves important functions in a community, if it is allowed to.