How does chance play a role in getting tenure-track and tenured positions?
At most schools in the US in fields where you do a postdoc, luck plays a relatively small role in getting tenure (because in the current job market the standards for getting hired are much higher than for receiving tenure), but luck plays a huge role in getting a tenure-track offer, in where you get a tenure-track offer, and in how long it takes to get a TT offer.  Here are several ways that luck factors in:


How many schools are hiring in a given year and how many positions they have.
Which schools are hiring in a given year and whether they have people interested in your work.
Who else in your field is on the market in a given year.  It’s very hard to be hired if you’re seen as the second best person in your subfield.
Timing of journal acceptances.  Having a paper accepted in a top tier journal makes a difference, but there’s a lot of luck in who the referees are and a lot of luck in whether the process takes a few months or years.


In consecutive years I had no interviews one year and over half-a-dozen the next year (with multiple offers) with all of the above factors playing a role.