Barrel length is almost irrelevant. Barrel uniformity and precision in profile, bore and rifling do matter. A lot. Stiffness (thickness) matters up to a point. You want a heavier, stiffer barrel, but it need not be a "bull" barrel.
If you are serious, look at barrels from Lilja, Kreiger, Shilen, Bartlein and other custom barrel makers. I have a Lilja 16" Recce profile barrel in Wylde .223 chamber, 1:8 twist that has the accuracy you are seeking, if used with match grade ammo.
There are many 16" and 18" sub MOA AR15 rifle barrel options. The only benefit of length is that it can give you a little more velocity so that the bullet does not go transonic and destabilize at longer range. With a 16" barrel that might happen out at around 700 yards, a longer barrel will stretch that somewhat, but a .224" bullet in a .223 case, loaded in a manner that it will cycle through an AR15 magazine is not very good for trying to shoot to 1,000 yards. You really need a different caliber for that.
A good match grade trigger and a free float rail (just about any free float will do -- your preference), are also essential. FWIW, the Lilja barreled rifle has a Geissele SSA-E trigger, which has a light 1.2 pound second stage. This is a "Recce" build so it commonly wears a QD mounted 3-9x40mm Leupold Patrol scope. But for precision shooting I use a higher powered QD scope. In this instance a now discontinued Burris Black Diamond 6-24x50 with 1/8 MOA per click turrets and a fine 1/8 MOA target reticle. That scope is useless for general use, but set at 24x or dialed back a little as needed to address mirage, becomes superb for shooting tight groups or smaller targets "way on out there".