Good question by the OP. Tesla's quality has ramped up quite rapidly. The later the production the better the quality, but also the higher the cost. Want to find that perfect production time to get the best quality for the least cost.
However, it does not always work that way. With all production vehicles their is always the luck of the draw. Two vehicles, produced on the same day, may have different issues. The pickier you are the more issues you will find.
I purchased a late January build 75X and it the quality has been far better than I would have expected, after reading these forums. It is smooth, quiet, fast and great handling. Best road trip car I have ever owned. Others seem to have every problem in the book.
To me, buying an inventory might increase the quality worry. Have to wonder why it is in inventory instead of being accepted by the original purchaser. To offset this worry, the price is usually less.
Think the best chance of getting the highest quality car is to order it new, and to your specifications. Best chance to get a no stories car. (Of course this has the highest cost.)
Sometimes, when ordering new, you get additonal bonus items that become included between the time of ordering and the time of production. Sometimes you wil also be happily surprised with a lower pick up price, as there has been a price reduction prior to your delivery.
For me, it resulted in an upgrade of a ordered 70 to a 75, a free tow hitch with plugs, a "un-corkable serial number, upgraded auto pilot computer and equipment, better tires, fold flat seating, and some other goodies. All pleasant surprises.
Best car I have ever owned.
YMMV.