A replicator is a device that transforms raw materials into finished products by reorganizing matter to fit a specified pattern. Replicators began to be common appliances among the major Star Trek civilizations in the 24th century.
Replicators use technology similar to transporters, but they do not have the same resolution. Consequently, replicated objects have "single-bit errors" that make them distinguishable from the object used to make the pattern. These errors are predictable enough to even identify the make of the replicator that created an item. Furthermore, the lack of resolution makes it impossible to replicate living creatures, and many non-living materials are also too complex to replicate.
While replicators are not energy-efficient (see below), they are extremely time and space efficient. The replicator "inventory" is a combination of data in the computer's memory and tanks and barrels of raw material, and most of the ship's waste can also be reorganized at the molecular level into new products. Complete technological devices like hand phasers can be produced from raw materials in a matter of a few seconds.
The Economics Argument
Trekkies often argue that replicators radically alter the economics of the future, creating a society in which anyone can have anything they want, thereby justifying the moneyless society of the Federation.
The argument is absurd because replicators do not create products from nothing: they require power, patterns, feedstock (raw materials), and maintenance. There are many products they simply can't produce, and many of the products they can make are considered inferior to similar products made by other means (which explains things like the massive popularity of Joseph Sisko's creole restaurant on Earth). The rationing of replicator usage in Star Trek: Voyager and the use of MRE-style stored meals instead of replicated meals on Defiant-class starships also show that replicators are actually less efficient than other manufacturing methods (drastically less, if the deplorably inefficient cooking methods of Neelix are still an improvement).
Consequently, replicators do not remove the supply and demand considerations of an economy; they just change the value and availability of certain commodities. This assessment is confirmed by the Ferengi economy, which continues to be a thriving capitalist economy despite the widespread use of replicators by the Ferengi.
Trekkies occasionally argue that replicators can create matter from energy, even though evidence from the show repeatedly refutes this claim.
There are also arguments that replicators can perform elemental transmutation, fusing lighter elements into gold, for instance, resulting in gold becoming "worthless". There is no real evidence that replicators are capable of such transmutation: there are many other reasons that the value of gold may have dropped in a high-tech society, such as advanced mining methods making it very easy to obtain. A need for rare elements might also explain why some items are impossible to replicate.
During the Dominion War, the Federation deployed a field of mines around the Bajoran Wormhole. These mines used replicator technology to replace mines lost due to contact with passing starships or anti-mine measures employed by the enemy. The mines shared a common pool of feedstock, sharing material in their storage systems with other mines to replace lost units. The range of the replication system isn't clear.
Clearly the mines must not have employed any materials known to be impossible to replicate, nor could any of the components be too complex for replicator resolution (which cannot accurately produce some microscopic structures). Since the mines were cloaked, the cloaking technology must not have required any unreplicatable components. Since replicators cannot produce anti-matter, they must have used some other reactant(s) in their warheads that could be synthesized from trace elements floating in space around the minefield. Presumably the mines could also make use of materials left by destroyed vessels or left over mine debris.
The replication and transporter activities of the minefield to replace lost mines did not compromise their cloaking, which is consistent with the use of transporters by cloaked starships.