In S04E15 of Supergirl, Nia Nal kisses Brainy, but after that Brainy tells her that the two of them can't be together. Why can't they be together?
Because Brainy is from the 30th century, and knows his history. He presumably knows exactly who Nia is "supposed" to be with in the timeline in order to eventually continue the line of Dreamer all the way along to the Legion of Superheroes in his time.
If he is with Nia, then he potentially derails that bloodline and erases his friend from existence. Or possibly he is his friend's many times removed ancestor and he just doesn't know that - yet.