This is the major problem that environmental economics has to deal with. The price of some ecosystem services (things that ecosystems do for free just by existing) can be pretty easily quantified. For example, a forested watershed will naturally filter out pollutants and prevent a water supply from being contaminated. We could calculate the value of this ecosystem service by finding out how much it would cost to put in a water treatment plant to eliminate pollutants in the place of the forest. You can know the price of things that are bought and sold on the market, like water treatment equipment, but the price for a nice view - that is more difficult. But we all agree that it has value to individuals and to society as a whole. Most people would be "willing to pay" something for that nice view. There are a couple of ways that economists use to try to quantify this "willingness to pay." They all have their flaws. Let's highlight a couple.
Travel Cost Method
This is a way of getting at the "use value"of something like a natural area that people like to visit. Basically you get an economics grad student to hang out at the site and pull people aside to take a survey about how much it cost them to get to the site. The survey might ask questions about how far they traveled, if they took a plane or drove, how much money they make, how much time they had to take off work, and how much they saved up to make this trip. This is a pretty direct way to get at how much someone would be willing to pay to be able to use the site, visit the site, see the site. Problem is, not every site or environmental resource is something that someone might visit. For example, the site could be hella remote, only enjoyed by penguins and polar bears. Or the site could be nothing particular to look at, just the home of some key endangered species.
Hedonic Pricing Method
This method compares prices of similar items with or without some environmental benefit attached to see how much extra people are willing to pay for the environmental benefit. For example, to figure out the value of a park you might see how much a three-bedroom house goes for next to the park compared to one that's a few blocks away from the park or in another neighborhood. This is problematic because no three-bedroom houses are exactly alike except for the neighborhood so there are a lot of statistics needed to try to isolate the variable you're interested in. Also, it has the same problems as the travel cost method as it is most easily used to define the value of a site that is close to human habitation and used for recreation purposes.
Contingent Value Method
This method is the simplest in theory. It consists of basically asking people - how much are you willing to pay for this environmental thing? Typically you ask them about how much they would be willing to pay to enter an area, or how much extra taxes they'd be willing to pay to see that area protected. You can frame the questions a million different ways, which could introduce some bias into the valuation. Also, there's a strategic bias in this method because the money that people would be willing to pay is hypothetical money. So if, for example, you were really poor but also a real tree-hugger (hey, maybe you live in a tree!) and someone asked you how much you hypothetically would be willing to pay to see a forested area protected, you'd say "All the money I have" or "a million-gillion!" Even though the reality is, you wouldn't ever be able to pay that much. Despite this bias, the contingent value method is kind of the only way to get a sense of the "non-use" value of an environmental resource. A "non-use" value is one that you give something just for existing, even if you never use it or visit it. For example, let's say that the sonar equipment from ships is making it too noisy for orcas to hear each other singing. This is making it difficult for orcas to navigate and to reproduce, decreasing their numbers. No-one really hunts orcas for meat anymore and very few people have the opportunity to see orcas, especially if you live in a land-locked state like Missouri. But, how much extra would you be willing to pay for your "chicken of the sea" to make commercial vessels reduce their use of sonar so that orcas could thrive? How much is it worth just to know that orcas will continue to exist?
All of these methods have a little bit of a flaw in that they are all based on either the public's behavior or the public's stated preferences. There are some unpopular environmental resources out there that have a really important role in balancing ecosystems. Wolves are a good example. Without these predators, deer and other herbivores's populations increase, causing overgrazing and biodiversity loss. This has multiple effects, some of which could directly impact humans, like increased tick-borne disease. But if you asked the average person how much they'd pay to have wolves roaming their woods, they would probably tell you how much they'd pay to have the wolves removed from their land.