why is the rainbow a symbol of homosexuality?

“The Rainbow Flag, created in 1978 for San Francisco’s Gay Freedom Celebration by Gilbert Baker, depicts not the shape of the rainbow, but its colors in horizontal stripes. The Rainbow Flag has been adopted as the Gay and Lesbian flag. It represents the diversity yet unity of Gays and Lesbians universally.”

From this site

The original rainbow flag was actually 8 colours instead of 6:
The originals were Hot pink, red, orange, yellow, green, blue, indigo and violet.

However, it was too hard in the '70’s to get hot pink fabric to make the flags, and traditionally the number of stripes is even (‘balanced’) so indigo was also removed.

The colours themselves are symbolic but I can’t remember what exactly they all were. Hot Pink was “Sex” IIRC.