It's not adversity. It's not "seeing what they got". It's a choice between:
1) staying in prison (or perhaps execution) and having the game basically end
2) agreeing to the DM's story
This is a terrible thing to do to any player and a reprehensible thing to do to a new player.
I don't get it. Every start of every campaign seems like it must begin with at least some sort of the "The GM tells you something you didn't necessarily decide to do." I'll give an example:
"So you are all sitting in this tavern..."
Is that railroading? I don't really expect one of my players to jump up at that point and say, "Don't tell ME I'm sitting in a tavern! My character doesn't even drink alcohol because of his religion! NO WAY am I going to be sitting in some tavern!"
My tacit agreement with my players is basically, "I'll tell you how it starts and you tell me how it ends." My campaigns very often start out with the PC's having agreed to a particular task or thrown into a circumstance not of their choosing. How they resolve that, and what they do once they have, form the rest of the campaign. I started off a Warhammer Fantasy Roleplay 2e game a few years ago with a statement that was pretty close to, "You wake in darkness to the smell of your own vomit. It is dark and you can see nothing. But you can hear the creaking of a ships hull, the clanking of the chains on your wrists and the moans of the others who fell victim to the Press Gang last night."
The players were fine with that because I told them from the start that this was going to be a game about Pirates and being on ships and rising to greatness from lowly beginnings. And that was the lowliest beginning I could think of. That was all part of the "buy in" conversation that we do before a campaign starts (though I didn't tell them about the Press Gang thing at that time).
I will grant however that these are guys I've played with for many, many years and they know I'm a Rat Bastard and also know that my games are, over the long haul, fun and not railroady. I'd probably explain to new players that "if things start bad at the beginning that just gives you more room for progress".
Lastly I'll say that, if you're going to run a "the PC's are in prison" situation, it's better to do it at the start of the game when they are far less equipment dependent than they are later on when they have a bunch of magic items and feats that tie into their equipment.