Barrel length determines the velocity of the bullet, and that has a significant effect on accuracy.
About 2.5" of barrel will achieve stabilizing spin.
Highest velocity is achieved when the full load of gunpowder burns behind the bullet prior to the bullet leaving the barrel. Muzzle flash is powder burning behind the bullet subsequent to its leaving the barrel (i.e., wasted potential energy). With greater velocity, the hyperbolic arc of the bullet is extended, making the bullet move in a "flatter" trajectory.
The rule of thumb for .308 shells is that it will take approximately 26" of barrel to completely use all of the powder as propellant. I'm not that sure about .223 powder charges, but my guess is that one should get a complete powder burn with between 22" and 24" barrels.
Anyone out there know more about this than me?
Also, there are a variety of other aspects that can have the same effect. For example, a tighter crimp can have a similar effect to a longer barrel. Different powders will have different burning effects.
Does anyone out there know if manufacturers hav experimented with barrels that initiate spin via rifling and then become smoothbores?