Will there ever be a moment when all eight major planets are in a straight line on the same side of the Sun?
Jean Meeus addresses this in Mathematical Astronomy Morsels (Willmann-Bell, 1997). He points out that you have to start by defining the question precisely. Let’s reduce the problem to two dimensions and ask whether all the planets can have the same heliocentric longitude (they can never line up in three dimensions because their orbital planes are all slightly different). Then, to simplify the arithmetic, we’ll say that two longitudes count as “the same” if they’re within 1.8° of each other.
Mercury, the fastest-moving planet, laps Venus every 0.396 year, staying within the 3.6° arc centered on Venus for 0.004 year every time. On each pass, the chance that Earth will also be within this 3.6° arc is 1 in 100. So, on average, the three inner planets line up every 39.6 years. The chance that Mars, Jupiter, Saturn, Uranus, and Neptune will all be within this arc as well on any given pass is 1 in 100 raised to the 5th power, so on average the eight planets line up every 396 billion years. If you tighten the definition by requiring the planets to be within 1° of each other, the time increases to 13.4 trillion years. Either way, the Sun will become a red giant, shed much of its mass, engulf Mercury and Venus, and allow the other planets to drift into radically different orbits long before such a lineup takes place!
— Tony Flanders