The mechanics of D&D deal largely with combat, because everything else can be taken care of with roleplaying. Saying that the sex doesn't contribute to the story is giving it short shrift. To look at it another way, if BG3 glorified violence it would be offensive, and if it used sex solely in a exploitative way, that would be meaningless, but I don't think either of these are the case. I remember Harlan Ellison describing gratuitous violence as violence that happens by rote, someone dies and it hold no meaning for the characters, which conditions the audience to feel the same. Nothing is gratuitous about the sex in Baldur's Gate.