One $17K rifle with a good sniper is a LOT cheaper (and more precise) than one Hellfire missile fired from a drone or aircraft. Particularly if there is concern about collateral damage.
A first-round miss also gives up the advantage of surprise - something critical for sniper engagement.
Parts: repair parts are notoriously expensive. Think of all the parts/pieces for such a rifle (any rifle, really): multiple springs, bolts, barrels, stocks, screws, magazine parts, special tools, suppressors, etc. for the rifle, scope, bi-pod, stock. Each one of them requires a National Stock Number (NSN), and perhaps some of those parts are already in the system and don't require a unique NSN (it all depends on the contract - for example, the contract may require that all tools required to repair the rifle are already availalbe in a standard armorer's tool kit). It costs $50 (one time charge) to just establish an NSN and about $250/year to maintain an NSN in the system. This is just entering and maintaining the number in the "system" - it doesn't include the parts themselves. Those parts - apparently included in the contract with Barrett - must be stored and maintained in multiple Army locations - depending on the level of maintenance required to replace that part, as well as with Barrett. Unlike the commercial world, a 1-3 week delay in getting the parts in a globally fielded Army is unacceptable, so ordering a part from a central location generally doesn't work. That means storing (and accounting for) parts all over the world and that is factored into the total cost. Many years ago, I taught Army Wholesale Maintenance Management (this was national-level logistics). While I don't recall the specific numbers, a real, valid study done by someone with too much time of their hands revealed that for the Army to buy a complete M151A2 Jeep, the price was about $6,000 (this was way back); the price of the individual parts in order to assemble a complete M151A2 was about $20,000...(this didn't include labor) Plus, for common things like screws/washers which may work, it's not like the shooter (or armorer) can go down to his local True Value hardware store in the wilds of Afghanistan (or the Arctic or jungles of South America or Africa) to get them.
Repair manuals: Yup, gotta have them: one set for the operator, one set for the unit armorer, one set for the direct-supporting unit, etc. Somebody has to write them and maintain them (updates/corrections), tailored to the soldier doing the repairs/maintenance, in multiple operating conditions. While much of this can be digital, manuals for the operator and possibly the unit armorer still need to be printed. This is sometimes included in the contract and Barrett needs to have some folks familiar with Army tech and format standards for the manuals. I believe Barrett also employs 24/7 immediate tech support world-wide, probably part of the contract. That isn't free.
Ammo: much of this is unique in the Army supply system. As with repair parts, ammo needs to be stored and rapidly available - anywhere in the world. If the contract includes X number of rounds for each caliber, there is the cost for that, too. I suspect the quality standards are a bit higher than commercially.
Operational requirements: Six-foot concrete drops are a standard survivability requirement for many items. That can make for a fairly stout rifle system, more so than what most personal owners would require (or even dare test). These rifles are being employed in places and harsh conditions no regular civilian would typically go, in world-wide climes from the Arctic (probably minus 40-70°) to the deserts of Saudi Arabia (up to +130°) to high-humidity conditions in the world's jungles. That is a pretty wide range of temperatures and conditions. How many here would take their primary sniper/hunting rifle through ocean surf and rely on it for your life for a few weeks? The SOF guys jump out of aircraft at 30,000 feet in extreme cold, drop through that cold air for a number of minutes, then deploy their 'chute and possibly go right into combat. So it is not just extreme temps, it is also a rapid change of those temps, while still expecting the rifle to fire - and fire accurately - upon landing.
Contractor support: usually included in contracts such as these, but there are limits both known and unknown as to how far forward this support can go and how extensive it is. Requirements stipulated in the contract along these lines are not cheap.
Training: gotta have, for operators and maintainers. This is usually included in the contract price, and includes training manuals.
Testing: operations to failure to determine Mean-Time-Between-Failure (MTBF) and Mean-Time-To-Repair (MTTR) are usually included in the contract. Same with operational testing to ensure these rifles perform in the required conditions. MTBF and MTTR requirements are typically in a contract of this nature. Somebody has to pay for that testing, and much of it is included in the item price.
All of these pump up the per-item cost; while the cost for much is constant whether or not the Army buys one hundred rifles or 20,000 rifles, the cost is stratified, for the same reason the cost of the F22 per-item skyrocketed when the numbers bought dropped precipitously. It might be called "overhead". Not to mention the cost of Barrett making the tooling and QC and building facilities to mass-produce (sort of) these rifles...all part of the contract price. And they still need to make a profit.