This page contains information regarding Star Trek: Lower Decks, and thus may contain spoilers.
The rifle was developed by Starfleet Security as a contingency for use in dampening fields or radiogenic environments where conventional energy weapons would be useless. It was designed to fire a chemically propelled tritanium bullet; in this, it was functionally very similar or perhaps identical to gunpowder arms, in essence "A Gun." A working prototype of the weapon was developed, but Starfleet opted not to produce the weapon after the advent of the regenerative phaser. While Starfleet didn't produce the weapon in any sufficient quantity, its replicator pattern was kept on file should the need arise, albeit access to it was limited to Starfleet officers.
The TR-116 could be operated by both right and left-handed shooters.
In 2375, Science Officer Chu'lak used a TR-116 rifle to murder fellow Starfleet officers Hector Ilario, Greta Vanderweg, and Zim Brott aboard the Bajoran space station Deep Space 9. Chu'lak modified the rifle with a micro-transporter, which allowed him to beam the bullet into another room, only 8-9 centimeters from its target. An exographic targeting sensor allowed Chu'lak to scan through walls and target victims anywhere on the station from his quarters. Lieutenant Ezri Dax later used a similarly modified rifle to stop Chu'lak. (DS9: "Field of Fire")
The TR-116 and its accompanying targeting sensor were designed by Production Illustrator John Eaves based on the Breen phaser rifle first seen in "Indiscretion". "[The script] called for this wild rifle with a transporter device attached to the barrel accompanied with a special headset sighting goggle." Eaves recalled. "We used one of the Breen rifles as the basic body and detailed and added all the extras to convert the piece into a new and deadlier weapon, the prototype TR-116 rifle." Eaves also believed the weapon to be chambered for .30 caliber rounds. (Eavesdropping with Johnny; Star Trek: Deep Space Nine Companion (p. 650))
The prop rifle itself was constructed of resin painted black and grey with rubber grip dressings, additional chrome accents and strap, and measured 35 inches in length. It was later sold off in the It's A Wrap! sale and auction for US$2,716.00.  One of the Breen rifles incorrectly labelled as a TR-116 was also sold off for US$2,500.  
Of the scene in which the weapon is introduced, the script for "Field of Fire" describes, "Behind them, the doors OPEN allowing O'Brien to ENTER carrying a high-tech rifle and wearing a targeting device on one eye. A small box-like device has been attached to the muzzle of the rifle." 
Director Tony Dow wasn't sure the weapon was going to work in "Field of Fire" due to the complexity of its design. "I thought it essential that we really see the insides of the walls", he recalled. "I mean, actually go through a wall so that the audience understood what was happening." (Star Trek: Deep Space Nine Companion (p. 651))
Visual Effects Supervisor Gary Hutzel was charged with creating the "seeing through walls" effect of the weapon. "The magic gun that shoots through walls!" he joked. "But that wasn't the gag so much as that you could see through the walls. That drove a whole lot of aspects of the effect. It had to look as if Ezri was looking through a scope toward a target that was a great distance away." Hutzel's team built a section of wall with its interior wiring and other components exposed. They then shot the prop wall from various angles so it could be used multiple times. Following this, they re-arranged the walls in the set that normally serves as Sisko's quarters, creating a number of smaller rooms. Inside these rooms, they photographed various extras. "In order to get the right appearance, we had a Steadicam operator run sideways past a number of smaller rooms so that the walls would be foreshortened in the foreground." Hutzel explained. "That gave everything the appearance of extreme distance, and the Steadicam gave it a handheld look, as if Ezri were looking through the targeting display. The operator had to run like nobody's business back and forth across the set and then come to a sudden stop, emulating Ezri's movements. He would run, run, run and stop, run, run, run back and stop." (Star Trek: Deep Space Nine Companion (p. 651))
In the Star Trek: Deep Space Nine - Mission Gamma novel Lesser Evil, Lieutenant Sam Bowers tells of his experiences aboard the USS Budapest during the Battle of Sector 001. The Budapest was one of a handful of Starfleet vessels equipped with prototype TR-116s. When the Borg attempted to assimilate the ship and its crew, Bowers led a security team equipped with TR-116 rifles through the ship, with orders to eliminate any and all Borg drones. Because the weapons used projectiles instead of energy beams, the drone's deflector shielding was useless, and the Budapest crew were successful in stopping the Borg.
Though these events are not mentioned in "Field of Fire", the statement about projectile weapons being effective against the Borg is at least partly supported by the scene in Star Trek: First Contact, during which Jean-Luc Picard uses a holographic Thompson submachine gun to kill two Borg drones.
In the novel A Time to Heal, a Starfleet security sniper used a TR-116 to stun Tezwan guards. It is noted that the gun can "shoot through walls", indicating that Chu'lak's modifications may have been adapted for field use.
In the Star Trek: Destiny novel Lost Souls, the TR-116 was stated to 10mm monotanium slugs. The weapon was later used to defeat a Hirogen boarding party and in the capture of a Borg vessel during the year 2381.
A variant of the TR-116, the TR-116A rifle also appears as a rare-quality "ground weapon" in the video game Star Trek Online. Players who pre-ordered the game through either Target or GAME received the weapon for free. The TR-116A had a different appearance to the TR-116 rifle as seen in the show, and dealt "Kinetic" damage to reference its projectile-based nature. The rifle's fire could also partially penetrate personal force field technology. When the game's crafting system was overhauled with the "Season 11" content update, a variant "TR-116B Sniper Rifle" weapon was introduced to the game and made available to all players. The B variant had a show-accurate appearance, and was also apparently equipped with a micro-transporter, as its secondary firing mode launched transported bullets that did high damage with a chance to knock an opponent back several meters. The TR-116B was also capable of completely bypassing enemy personal shields, making it an ideal weapon to use against Borg.  
The weapon can also be crafted by players in Star Trek Timelines for use by the rare character "Sniper Ezri Dax", who holds the weapon in her left hand.
In 2007, Diamond Select Toys released an Ezri Dax action figure complete with TR-116 rifle and eyepiece.