Sex and violence are inherently more interesting in stories where the reader can't be sure that a character or a relationship will survive.
In sex scenes, the relationship that changes doesn't have to be that of the characters having sex: If someone learns that two people they love have become lovers, their relationship with them will be affected.
In action scenes, the character in peril doesn't have to be the main character. if we, the audience, know a character will live, we can't be afraid that the character will die, but we can be afraid that the character will fail.
At the end of the first season of Veronica Mars, the writers made a big mistake: Veronica was in a death trap, and her dad was trying to save her. We knew Veronica couldn't die; she was the title character. We knew her dad couldn't die; if he did, he couldn't save her. The only suspense came from not knowing if the villain would escape, be captured, or be killed. We were simply watching to see how the story would end. But if Veronica's dad had been trapped and Veronica had been trying to save him, we would've been on the edge of our seats for every instant.
So, to make this very simple:
Daniel Boone fighting a bear is boring. Daniel Boone fighting a bear to save his wife is interesting.
Daniel Boone having sex with a bear is stupid and boring. Daniel Boone having sex with a bear when his wife might discover him is stupid, but interesting.