To what extent does the prospect of a guaranteed-for-life job (tenure) motivate researchers to stay in academia?
I'll respond based on anecdotal evidence, but over 30+ years, worrying about my several PhD students, and partly in a role as director of grad studies in math, giving career advice, etc. My experience is in math, not comp sci, though.

In any case, even 25 years ago, it was clear (both anecdotally and documentably by the AMS at the time, although not so accessibly, due to lack of internet...) that the "golden days" of academic math (at least) were waning, because of growth of PhD production that surpassed growth of academic positions. There had indeed been a boom of branch campuses, but that had roughly stabilized c. 1990. Some very good people (including some of my own students) got tenure at a branch campus in rural areas, but/and decided that the heavy teaching load and isolation was not what they'd signed on for.

By the mid-90s, the job market was consistently tight enough so that new PhDs with partners very often opted for non-academic trajectories, but so they'd not have to commute crazy distances, and so they could have a family with both parents participating. Hard to argue with that. The former "monastic" model of academe, or of infinitely-accommodating spouse, etc., is not acceptable these days. (I've tried long-distance stuff myself, too, and, sad-to-report, it really only works well when one is secretly glad to be apart... uh,...)

In the last several years, some of the most able and motivated grad students have had the sense to realize that, in particular, their chances to make a big-enough contribution to get a permanent job at an R1 place were pretty slim... and they didn't want to stay in academe "at all costs", so shifted their energies to avenues where being smart, motivated, and hard working had a better chance to pay off (these days). (See @DavidZ's comment.) 

I've followed up with some of the people who did stay in academe and settled in relatively remote areas at small branch campuses, and, while they're "ok", they have "confessed" that it wasn't at all what they'd hoped for. Some speculation (obviously plausible) that without forced retirement, there's a lot of "waiting around" for better positions to open. (Not unlike situations in Europe, as I gather from friends there, where saturation had occurred much earlier, apart from mandatory retirement issues.)

The palpable corporatization and commodification (or at least the greater visibility of it) of higher education does also seem to have a consistently disenchanting effect on undergrads' choices about what to do after their B.S. in math (e.g., going to work for an insurance company... is (even?) more attractive now than it may have been in the past, and for some people seems vastly more viable than "grad school"...)

Although I suppose one should always be wary that possibly one's own cumulative disenchantment interferes with perceptions of others' opinions, I do have a rough idea of our local "stats" about academic versus non-academic positions for PhD'd people: once upon a time, everybody went into academe, but nowadays perhaps as many as 1/3 of each year's PhD's do not.

Even disregarding the mandatory retirement issue, it's simply not a time of expansion for higher ed... but/and the element of Ponzi-scheme of academe has no mechanism built in to reduce PhD production without finding someone else (adjunct faculty!?!) to exploit... or else (in the case of math) teaching loads would skyrocket, etc.