There are always shows that take you by surprise. Nicole Taylor’s five-part drama The Nest, which concludes tonight, is one of them. When this surrogacy thriller kicked off, it had the look of another enjoyably glossy slice of hokum. In the vein of Gold Digger, Doctor Foster or Flesh and Blood, it seemed as if it would be the kind of programme you watch as much for the characters’ lifestyle choices – in particular the sleek loch-side house that protagonists Dan (Martin Compston) and Emily (Sophie Rundle) Doherty live in – as for the actual plot.

We couldn’t have been more wrong. Taylor, who wrote Three Girls and film Wild Rose, has always been an ambitious and subtle writer, and the house that the Dohertys live in isn’t simply a nice bit of property porn but rather a symbol of their privilege in a rapidly changing Glasgow. Similarly, as the drama has twisted and turned, shifting our sympathies from one character to the next, so it has become increasingly impossible to predict how it will end.

With Dan and Emily seemingly happy to accept their baby despite the murky circumstances of her birth (even Taylor isn’t averse to the old “mixed-up embryos” plot twist), the biggest question remains the one over Doddy’s death. Was it a gang killing, as hinted at by last night’s bleak (and clever) ending in which social worker James (James Harkness) was arrested for having accessed private information and then handed those details over to a local Mr Big? Or could Dan or teen surrogate Kaya (the magnificent Mirren Mack) be more involved than we know?

What about Dan’s Mr Fix-It, the sinister Souter – how far might he be prepared to go to protect the man he clearly views as both surrogate son and investment? And what of journalist Eleanor (Katie Leung)? Is she, as she claims, simply trying to protect the vulnerable Kaya, or does she have another axe to grind?

‘Who gets to have ambitions in life and who doesn’t?’ ... Sophie Rundle as Emily and Mirren Mack as Kaya. Photograph: Mark Mainz/BBC/Studio Lambert

Will we find out why Kaya stabbed a pregnant woman to death at age 11 – and do we need to? A large part of The Nest has centred around the idea of redemption, and it’s clear that Kaya knows the awfulness of her crime and deeply regrets it. Do we really need to know more than that she is “Scotland’s Mary Bell”?

Can Hilary (Fiona Bell) save her marriage and reconcile with her son or will she continue to put her brother’s needs above her own family?

Perhaps the biggest question of all remains: can Kaya – whose last solid pillar, James, has just been removed from her life – manage to find the stability she so desperately craves, particularly when her malevolent mother (a scene-stealing Shirley Henderson) is edging ever closer?

Whatever happens, one thing will be clear: Taylor’s clear-eyed script will continue to contrast the glittering Glasgow of Dan Doherty’s property empire with the precarious lives of those scrabbling around its edges. As the series has progressed, it has become increasingly obvious that this is not so much a thriller about surrogacy as it is a fierce commentary on aspiration, class and success – on who gets to have ambitions in life and who doesn’t.

When James was arrested at the end of last night’s episode, he didn’t give us the stock TV villain’s justification but something more interesting and believable. Here was a man trying to make a difference, trying to provide for his daughter and help people start again; but he was also barely making enough money to get by, he was worried that he couldn’t provide for his child and increasingly concerned that he would lose custody of her. Seeing an easy way to make money on the side, he took it, and justified it by thinking of those he set up as “druggie scum”.

‘A man trying to make a difference’ ... James Harkness as social worker James and Mirren Mack as Kaya. Photograph: Mark Mainz/BBC/Studio Lambert

That notion that some people know better than others (or rather that some people believe they do) looms large over The Nest. We see it in the uncomfortable relationship between Dan and Hilary, who raised him from when he was a “wee bampot” and who he has attempted to repay by picking up her sons’ school fees and covering her mortgage.

Yet with that good deed comes a certain expectation of subservience. It’s an attitude that threatens her marriage and her relationship with her elder son, Jack. Similarly, when Emily, who tries to wear her middle-class privilege lightly but doesn’t always succeed, learned that the baby Kaya delivered was the result of an embryo implantation mix-up, her immediate reaction was to try to find “her” baby, the “real” baby; whereas Dan instinctively understood that the baby Kaya gave birth to was the baby that they were meant to raise. For the Emilys of this world, Taylor suggested, love can be conditional: if things don’t work out, you pack up your emotions and think about walking away.

Nowhere is the discordance between those who assume life will provide for them and those who have to fight for every crumb more obvious than in the character of Kaya. In a lesser series, Kaya would be reduced to psychopath or avenging angel, little more than a plot device to remind the middle classes of the perils of trusting those not among their own. Not here, however.

If there is a driving force behind Taylor’s drama, it is a furious awareness that the Kayas of this world make people uncomfortable, and that we prefer to ignore them rather than look at why they act as they do. We dismiss them, refusing to acknowledge that they might have dreams and desires of their own. Taylor, aided by a lovely, subtle performance from Mack, shows us repeatedly how very unfair that is. Kaya might be damaged, difficult and struggling to overcome a terrible past, but she is also warm, caring and desperate, above everything, to be loved.

Will she achieve the happy ending she longs for? The odds are stacked against her, yet despite everything, I can’t help hoping that she does. It would be an intriguing conclusion to a show that has consistently defied our expectations.

• The Nest concludes tonight, 9pm, BBC One.