Aftermarket barrels tend to be made with more care and precision. They are generally hand-lapped after the rifling process. Which also seperates factory barrels from aftermarket... Most aftermarket barrels are cut-rifled, but some are button-rifled, and a few are hammer-forged. Aftermarket match-grade barrels are also air-gauged to super-tight tolerances for consistancy. Also, their quality control standards are generally MUCH tighter than with mass manufactured factory barrels. Most factory barrels are hammer-forged, which is inexpensive, but when done right, can also be a precision barrel that will last a long time. Which is why you can generally make a factory barrel shoot pretty good with some hand or fire lapping, load development, and handloading for it. Granted, that won't work all the time (there will always be lemons out there), but more often than not, an experienced handloader can figure out if it's a shooter in about 50 rounds of load development, after break-in.
I have lots of semi-custom rifles that have worked-over factory barrels, that have been bore-scoped, re-chambered, hand-lapped, and then custom crowned. The cost is minimal since my smith is a friend of mine, and he knows how to make factory Remington barrels flat-out shoot... But, when those barrels get shot-out, I will be going with aftermarket barrels. Most likely Bartlein, since they offer the twists and contours that I prefer for my rifles, and they are cut-rifled 5R barrels. I have become quite the fan of 5R rifling since my first Remington 5R Milspec in 2009/2010.
So, also to re-state what the others before me have stated, aftermarket barrels give you alot more options for twist rates and contours, and rifling styles and patterns, than what you get with factory barrels. With factory barrels, you pretty much get what you get. With aftermarket, you not only have the benefits I stated above, but you also get a whole new world of choices to make your rifle better suit your needs for it.