It was Shae's fault she got caught in the end. Tyrion warned her from the very beginning that no one could find out about them and that she had to be careful, instead she was constantly careless and eventually one of Cersei's handmaidens caught her. Her refusal to heed the the many warnings and over confidence got her in trouble. Finally when Tyrion was forced to turn on her to save her life, she turned on him, but what do you expect?
She was forced to watch Tyrion marry Sansa, and be her handmaiden. Probably not fun being a part-time lover. Tyrion offered to buy her a house in the city, Varys gave her a sack of diamonds to move away, paid for her to leave, but she refused. She was a whore for many years, she was paid to do what men wanted. Only this wasn't about the money to her, not anymore, she was in love with Tyrion, she respected and had admiration for him, and that was obviously more important to her in the end, she wanted him, not his money.
Tyrion fucked it up just as bad as she did though. He knew she shouldn't have come to KL with him, he knew what happened to the last whore he fell in love with, he knew that having her in KL would cause problems, but he took her anyway. He led her to believe that there was a future for them, because for a while he was dumb enough to believe that there could be. He wanted the best of both world's, he wanted to remain a Lannister, he felt like he had something to offer, to the realm, to the Lannister legacy, he wanted to prove that he was more than just the God of tits and wine. He should have known better than to think that his father would ever see him as anything other than what he was, someone Tywin despised.
Shae wasn't a bad guy in the end, she was just someone with a broken heart and someone important to Tyrions growth because it was all of these events that woke up him from reality, he wasn't a Lannister, he was never going to be and he was never going to get respect in KL, he would never find happiness with whores, he couldn't, and no longer even bothered as seen in S5. Her death, Tywins death, the trial needed to happen for him to become the person he is right now, Hand of the Queen.