The first part of this play lays the foundations for tragedy in a very naturalistic, psychologically realistic way. The second part introduces several contrived mechanisms for resolving the conflicts and ensuring a happy ending — in other words, it seems dictated by folk logic. Does it all hang together?
The answer depends, in part, on how consistently we think the characters behave in response to those contrived plot twists: If the characters' reactions and choices make sense, given what we have learned about them in the first part of the play, we're more inclined to overlook the contrivances and feel the play is integrated.
I think you can argue that there is some continuity, particularly if you judge the characters according to the values of their culture. The Duke is ultimately responsible for the central conflicts in this play. He's the one who sets Angelo to the task of reforming Vienna, which indirectly leads to the arrest and sentencing of Claudio. He also orchestrates the plot contrivances in the second half of the play. If we want to argue that Shakespeare successfully unites both parts of the play, we need to see continuity in the Duke's motivations as well, and there is an important break.
The result helps along the plot by making a happy ending possible according to folk conventions. It undermines the unity of the play, though.
To see what I mean, consider how the two parts of this play differ. In the first half, the action seems to flow naturally from the psychology of the characters. Angelo, the self-righteous moralist, is prepared to carry out the sentence of the law because it meets with his conceptions of justice. He discovers that he lusts after Isabella, though, and is capable of a cruel immoral transgression— bargaining to spare Claudio's life if Isabella will have sex with him. Isabella—steeped in Elizabethan mores and in training to become a nun—is committed to her religious beliefs, which compel her to reject Angelo's offer out of hand. As Northrup Frye noted, the first half of the play presents us with a "binary opposition" that seems to lead, inevitably, to "tragedy's brutal choice: rape or death."
This psychologically realistic part of the play reaches its climax when Isabella and Claudio meet in the jail. Claudio, faced with threat of execution, questions whether his sister might sacrifice her virtue to save him, and she responds vehemently in the negative. Her religious beliefs clearly indicate to her that her virginity matters more than anyone's life.
Is't not a kind of incest, to take life
From thine own sister's shame? What should I think?
Heaven shield my mother play'd my father fair:
For such a warped slip of wilderness
Ne'er issued from his blood. Take my defiance,
Die, perish! Might but my bending down
Reprieve thee from thy fate, it should proceed.
I'll pray a thousand prayers for thy death,
No word to save thee.
This leads to the turning point of the play because the Duke, disguised as Friar Lodowick, has overheard the siblings talk, and he steps in with a convenient solution that will save Claudio without forcing Isabella to submit to Angelo.
He tells Isabella the story of Mariana, who was engaged to be married to Angelo. Angelo backed out of the agreement, in a way that, according the folk morals of Elizabethan England, brought great shame to Mariana and showed Angelo to be worthy of condemnation. The Duke proposes the "bed trick," in which Isabella tells Angelo she will go through with his proposition, but only in the dark and quiet. Mariana will secretly take Isabella's place, and when the truth is later revealed, Angelo will be forced to marry Mariana. Isabella and Mariana both agree to this, and the switch is performed.
This is a good example of the shift from a psychologically naturalistic story to one that seems direct by the demands of folk-logic and a happy ending. Some critics may argue that the women are being hypocritical, because Mariana is doing precisely what Isabella condemned as immoral; I disagree because in the eyes of Elizabethans, it wasn't the same. Mariana's marriage engagement and Angelo's breach of promise justify Mariana's act. What's more of a problem is that the entire solution drops into the play like a deus ex machina: it's highly convenient and doesn't relate to anything that happened previously.
Moreover, it isn't just a convenient plot contrivance for turning tragedy into comedy. It also creates discordance in the portrayal of the Duke. At the beginning of the play, the Duke explains that he is handing his power over to Angelo for a short time. He indicates that he wants Angelo to start enforcing laws that the Duke allowed to be ignored—the Duke feels he has been too permissive and hopes Angelo will turn things around. He later confesses another purpose, too: He is testing to see if Angelo will fail to live up to his own moral principles:
Lord Angelo is precise,
Stands at a guard with envy, scarce confesses
That his blood flows, or that his appetite
Is more to bread than stone; hence shall we see,
If power change purpose, what our seemers be.
Can Angelo be corrupted—will he prove himself to be a scoundrel? The problem, now, is that it seems the Duke knew all along about Angelo's treatment of Mariana, and he condemns Angelo for it, noting that Angelo:
Left her in her tears, and dried not one of them with his comfort; swallowed his vows whole, pretending in her discoveries of dishonour: in few, bestowed her on her own lamentation, which she yet wears for his sake; and he, a marble to her tears, is washed with them, but relents not.
So there is a serious discontinuity here between the Duke's apparent psychological motivations in the first part of the play and what we learn now. The Duke already knew that Angelo was capable of corruption, so his explanation in the first part of the play is inconsistent.
Another potential inconsistency is Angelo's decision to execute Claudio even after he believed Isabella had kept up her part of the bargain. In the first part of the play, Angelo argues that if he broke the law, he would condemn himself the same as any man. Yet now he departs from this, and our only account as to why comes in a soliloquy near the end of the play:
I should have let Claudio live,
Yet his youthful lack of restraint was bad
For the times, and his depth of shame would give
His life dishonor. Still I wish he had
Lived. When once we have forgot our virtue,
All goes wrong. What I should not do I do.
In the absence of understanding Angelo's decision, we're left to wonder if Shakespeare did it merely to further the plot. It's important for the final denouement that Angelo behave as reprehensibly as possible.
Finally, another example of a convenient plot twist is the death of a pirate resembling Claudio. When Angelo demands to see the severed head of Claudio, the Duke instead arranges for Angelo to see the head of a pirate who died of natural causes. Again, the plot is forwarded without a violent loss of life. It serves the need for a happy ending. It doesn't reflect a turn of events that grows naturally out of the characters' psychologies.