I read this over at Pennsylvania Firearms Owners Association. It was posted by a user named, djak. Makes for an interesting read for a beginner like me.
The physics behind shooting a bullet have many variables. Yes, long barrel length gives higher velocities, which affects external ballistics only. The faster the bullet can reach its' target, the less wind can impact it. Also, the horizontal force (shooting the bullet downrange) is magnified against the vertical force (gravity), so you shoot flatter.
But what truely causes accuracy in a rifle, assuming the remaining internal ballistics remain constant, is the harmonics of the barrel. The barrel will vibrate almost like a guitar string. What you want for accuracy is for the barrel to emulate a simple harmonic motion. What this means is that the muzzle will be in the same exact place every time when the bullet exits and since a guitar string is attached, it will, but the muzzle of a rifle can go anywhere. This is why loads with different amount of powder in them are not accurate (minus the vertical stringing). The barrel is exerted under different amounts of stress. Try flicking a string with different force and you will understand what I mean.
The above guitar emulation of the barrel with simple harmonics means that the barrel acts like a "standing wave" and the amount of work done is zero, which is a GOOD thing.
To increase your accuracy at long ranges, have a stiff metal (ie stainless), or a thicker barrel. Also, do you understand lock time? There is also what I call barrel time. That is the time it takes for a round to exit the barrel. The longer amount of time a round is in the barrel, the more likely you will change the direction of exit from the original direction. Just like with a firing pin's lock time.
Now, for advantages of longer barrels..... the increased velocity. Not only as I said before about the horizontal component of force, you also have to recognize different air pressure barriers. The most important is the 1st sound barrier. If a bullet is exiting at that speed, or tries to stablize within that realm, you will have serious accuracy issues.
A good example is the 17 Mach 2 (obviously exiting the muzzle at mach 2). It's velocity exiting the muzzle never allows the bullet to "grab" good air which reduces accuracy (remember you will only shoot this round out to 100m "effectively"). Take this idea and apply it to powerful center fires. A 7.62 by 51mm becomes "uneffective" at a range of about 800 meters. This is because it's velocity enters the sound barrier, unstablizing the round, not because of a lack of energy. You can increase this range by increasing muzzle velocity or you can ruin accuracy by increasing a velocity into this barrier, so choose wisely.
I shoot a savage 112 with a kreiger 1.25" straight barrel at 20" long. It will out now out shoot the 24" barrel that originally came on it (Also a excellent barrel). But since I do not care about shooting past 500 yds with this particular rifle, I gave up velocity for strength while keeping the weight of the barrel down and trying to reach that perfect simple harmonic, and because I shoot 115 gr rounds with a very high BC, I still shoot very flat out to my intended ranges.
By the way, online I have seen kits that will "bed" your barrel at different points. What it is looks like a cleaning rod on a SKS (kept under the barrel), but what is "does" is allow you to tune the bedding by twisting this rod. I guess it moves a bedding material up and down the channel of the stock. Idea is good, don't know about its' engineering though.