Ferengis are all about acquisition and making a profit. But, in the age of replicators, where everything you want can be produced instantly, what would be the point of their lifestyle?
Replicators still require raw matter and energy to function, both of which can be charged for. Also, not everything can be replicated (latinum) and other items would be too big to replicate in your standard replicator system (such as a starship).
In other cases people may just prefer the "real" thing to something replicated. Food for instance; someone may prefer ground grown food over replicated food. This would be an especially lucrative market for food that can not be produced on the local planet.
Before the Ferengi encountered the Federation, they were already an empire whose primary interaction with other alien civilizations was the establishment and continuation of profitable trade. This culture of trade is embodied within their Rules of Acquisition, which are a series of cultural mores built around what the Ferengi consider policies of successful, if not less than honest, trade agreements.
The Ferengi culture was centralized around the concept of greed and profit earning. As Quark once put it, "There is nothing beyond greed. Greed is the purest, most noble of emotions." Finally, the 10th Rule of Acquisition states that "greed is eternal." (DS9: "Prophet Motive")
Where most species developed warriors, the Ferengi developed complex cultures of mercantile advancement.
Unlike most other cultures who frequently idolize warriors or politicians, businessmen were the pillars of Ferengi society for millennia. This tendency led to the slow merging of business and political fields in Ferengi culture and that influence was evident in the near-universal application of the Rules of Acquisition, as both a personal and financial code of ethics.
Their interactions with the Federation would be more challenging because many of the more advanced races of the Federation would have access to replicators, a technology capable of creating material objects using replicator templates and an unnamed source matter.
A replicator was a device that used transporter technology to dematerialize quantities of matter and then rematerialize that matter in another form. It was also capable of inverting its function, thus disposing of leftovers and dishes and storing the bulk material again.
Replicators can create anything that is stored as information within their databases.
As a result, a person can get anything that has been described and stored as information including various foods from many worlds, machine parts or even completed devices if the entirety of the specification was available.
This was why when personnel are restricted to quarters, their replication capacity was either eliminated or restricted. Federation replicators cannot be used to replicate poisonous materials at any rare.
It would seem many people in the Federation would have no use for trade, but that is a misnomer. The process of replication requires an enormous amount of energy very similar to that of a transporter, since it is effectively manipulating matter at the atomic and molecular level.
Replicators were capable of producing something as fresh and tasty as non-replicated foodstuffs, inorganically materialized out of patterns used by the transporters. (TNG: "Lonely Among Us")
Most people found replicated foods and drinks to taste exactly the same as "real" food, although some people claimed to be able to tell the difference. Furthermore, Federation replicators could be programmed to produce foodstuffs of acceptable "nutritional value". (TNG: "The Price", "Sins of the Father", "The Wounded", "Relics"; DS9: "In the Pale Moonlight", "You Are Cordially Invited")
In addition to foodstuffs, replicators could be used for replicating machine parts, clothing or other objects. Although clothing can be replicated for general wear, replicators will not allow non-Starfleet crew members to replicate official Starfleet uniforms. Industrial replicators could even be used to replicate heavier machine parts. (TNG: "The Game"; DS9: "For the Cause"; VOY: "Caretaker", "Phage")
Replicators aboard Starfleet vessels would not produce fatal poisons. (VOY: "Death Wish") Furthermore, replicators had biofilters which automatically screened out all contaminants. (DS9: "Babel")
The process of replication still requires energy which must come from somewhere, even in the energy-rich Federation. While the Federation would appear to have a nearly limitless supply of energy given their matter-annihilation driven technology, in truth, such advanced energy technology is not available on every Federation world.
Worlds which utilize fusion energy (impulse power) may restrict the amount of energy spent for replication even though impulse power can be used for replication and even transporters if regulated properly.
It is believed the development of the highly sophisticated level of the replicator in the 24th century which would account for the post-scarcity perspective of the Federation. At this point the replicator technology was ubiquitous to most ships, most advanced facilities and could even be made portable to be sent on repair missions for making parts and other equipment.
Why wouldn't a Ferengi just use a replicator?
But one of the reasons a person might not want to use a replicator could be based on the idea they might want a particular product not found in the Federation replication database.
With thousands of worlds, and trillions of potential artisans, there is always likely to be someone out there producing a work of ART that is not within the replication database.
These objects may be made by without automation, often by hand having the associated physical, cultural and psychological baggage associated with making something personally.
Technically, any work of art could be deconstructed and recreated perfectly but it would lack the touch of the artist beyond what was originally created. (Yes, you could also use a computer to alter each piece, so they appeared to be unique but this would still not be a work of art in the classic sense that an ARTIST created it.)
Trade in materials not accepted or able to be replicated by the Federation
The Ferengi may continue to offer trade options in materials that are:
- Difficult to replicate including heavy metals with unusual or unstable atomic or molecular models (such as Latinum), synthetic compounds, complex molecular structures, delicate organic compounds or even poisons might still be traded by the Ferengi to races within the Federation.
Latinum is a rare silver-colored liquid that was used as currency by the Ferengi Alliance and many other worlds. It could not be replicated. For ease of transaction, liquid latinum was usually suspended within "worthless" gold as a binding medium to produce gold-pressed latinum. (DS9: "Who Mourns for Morn?")
Such trade may be technically illegal within Federation boundaries but since it may originate outside the Federation it is harder to regulate or control.
Many Federation worlds may interact with species outside the Federation who may possess technologies or capabilities beyond current Federation science, art or technology. The Ferengi likely facilitate this trade to their economic benefit.
Trade is not dead in the Federation, it simply is more complex due to the inclusion of a science (replication) that allows simple objects to exist with no more effort than modern mass production. This still leaves plenty of room for artist expression, scientific advancement, or cultural drift to create new expressions for the Ferengi to trade in.
The Ferengi, of course, would prefer to trade with races who do not possess the ability to relatively easily, reconstruct matter into any shape they prefer, since it reduces their ability to create commodity markets where profits can be standardized and controlled/exploited.
The Ferengi likely consider the Federation as a whole, particularly where replication is easily available, a poor customer. Treaties with the Federation ensure there will always be somewhere replication is not easily had, thus allowing the Ferengi to create some Profit.
While it is not one of the known Rules of Acquisition, the Ferengi might say "Trade cannot be replicated."
Maybe it helps to frame this question in terms of modern technology - we live in an age of printers. Most people have access to high quality printers at work,school or home. We also have photocopiers and scanners. Even with all these "paper replicators" there is still a huge market for materials like books, newspapers, artwork, notebooks, pens, papers, etc.
Yes, and it's a plot hole you can drive a self-contained world five miles long through.
It's also an equally large plot hole that all Ferengi are all-consumed by their rules of acquisition. And that the Klingons are all-consumed by a need to die (not just fight, or fight bravely, or destroy all your enemies by hook or by crook, but die) in combat. Or that the Vulcans are all-consumed by the need to be logical. Or that an entire planet can be an all-inclusive resort filled with only the prettiest 20 year olds. No civilisation (nevermind a planet full of them, or worse, an empire of many different planets) can possibly be made up entirely of one class of people, even if that class is "businessmen". This kind of extreme specialization will inevitably result in the group being completely wiped out by someone who doesn't play by the same rules. Like humans with their replicators. Or Klingons and the first person that comes along that fights unfairly with the intention of surviving the battle at the expense of everyone else.
In addition to all the great answers and comments: Ferengi also trade and provide... information. Things, that can't be replicated and that in many situations or contexts are much, much more valuable than all the latinum, replicator rations and energy to power these replicators.
I would even risk an assumption, that if at some point latinum would become replicable and when all the things you can get out of replicator would become as good as hand-make, so you couldn't say the difference, then the Ferengi federation would still exists and perform well on exchanging solely information.
In this matter, the 24-th century world does not differs too much from our own. As you can see on many examples, a proper information, obtained in a appropriate place and time, is more valuable than all the gold or money you can have.