I'm not a huge fan of it but I suspect there were meta-plot reasons for it.
One reoccurring theme in last night's episode was reemphasising shades of grey; lots of characters who tended to come across well to the viewer had "bad" moments. Littlefinger's betrayal of Ned Stark had sort of been subsumed by his political games and magnificent bastardness... so he ramps up the sinister Irish accent (I can't recall it being that pronounced previously) and has Hollard shot. People were falling for the redhead wilding and OTP'ing her and Jon... so Ygritte shoots a defenseless farmer in the head and takes part in the sacking (and slaughter) of a village. Everyone hates Cersei... so she has an episode where she actively does nothing wrong, her major positive trait is emphasised and instead is abused. The odd-couple of the Hound and Arya are producing some good comedy moments... so the Hound beats a(nother) defenceless farmer and steals what little he has.
I think the rape falls into that. Jaime started the series as the arrogant man who slept with his sister (pretty much making him the direct clause of the majority of the conflict during the show) and tried to murder a child when caught. Since then he's had much of his character rehabilitated and become someone fans can sort of root for following his capture, imprisonment, journey back to King's Landing and cold reception when he gets there. So now the point that despite all that he's also still a pretty nasty piece of work gets reemphasised with the rape.
As I say I'm not a huge fan of it... I tend to dislike the frequent use of rape in media at the best of times... and I rather fear it will either lead to radical plot changes or some scenes not really making sense. But it did theme into the overall theme of the episode.
"Cersei fucked Lancel?"
Their relationship, Cersei and Jamie, never did make a lot of sense. And once the lust/passion leaves it, it's a giant unraveling that ultimately leaves Cersei alone in King's Landing. That didn't change, despite the narrative changes of the series over the book series. At least, it doesn't seem to have. I guess we'll find out when/if Jamie takes Riverrun.
Jamie's about my favorite character, and the only thing that bothered me is a N/C doesn't really fit Jamie's character. He's killed men for rape before, even when, "everybody done it." For a man with no honor, he has a surprising amount of honor once he loses that hand.
According to the Director of the episode, Alex Graves, the sex turned consensual by the end of the scene. I'm not sure, though, that's clear to the audience.