Does the profit from selling duty-free items on board justify flying the carts?
Okay so there are a few points to this


Lots of different things are sold - perfumes etc, gifts, "in flight" convenience items such as headphones, plus food/drink. That means lots of sales opportunities.
"Luxury" items are high margin anyway: perfume is a big profit item even with duty. By knocking the duty off and making it "feel" cheap: they can potentially sell it for more than the RRP (minus duty), and thus make more profit than a regular shop, despite selling it for less (gross) to the passenger
You only need to carry one or two bottles of each perfume, as you won't sell a ton of them. They don't take up much space: perfumes etc are only sold to one or two people per flight, they're not the reason the cart is there... they're just an extra. Similarly headphones: you won't sell many, but you'll definitely sell some when somebody realises they left theirs at home: I bought a set of cheapo £2 headphones for £8 at a train station a few days ago because wasting £6 on a set of crappy headphones was better than the idea of a 5 hour train without any music. People will pay for convenience, and carrying one or two of these items doesn't take up much space at all.
Food/drink are the reason the cart is there. When on a flight for 1-4 hours, some people are going to be hungry/thirsty... and you have anywhere from 100 to 850 passengers. The markup on these items can be huge - £6 for a small can of beer, for example, which would cost &lt;£0.30 from a wholesaler. You don't need to sell a huge number of pies/burgers/cans of beer/£3 cans of coke to make a decent profit. With the air-con on a plane, I find I get very thirsty and will go through a 500ml drink roughly once an hour. Similarly on a 4+ hour flight I'll tend to want a snack or meal at some stage. I'm certainly not alone in this.
Seats on these planes aren't always that expensive. On my last flight it was less than £40 for my one-way ticket on a 2 hour flight: if the trolley takes up roughly one seat's worth of space, they only need £40 in profit (or perhaps 20 cans of coke in 2 hours, at £2.50 per can) to be worth carrying a trolley. Similarly the longer the flight, the more likely people are going to be thirsty. With 190 people on board, even if only one in 10 buys a drink, that trolley has made more profit than my seat. Even considering an 8 hour transatlantic flight with 400 people on board a 767, that still only needs half the flight to buy one drink (which they probably will in 8 hours...) to make up for my £500 seat
It's expected, and is a service to some extent... people would start getting quite annoyed if they found they couldn't get a drink on the flight, even if said drink is expensive. People tend to expect to be able to get a drink, if nothing else, but usually food too. Notice that most non-local (2hr+) trains (and many local ones!) tend to have a trolley service or, more and more often, a shop on board? Even if it didn't make a profit at all, it may be worthwhile for customer happiness. This is a bit of a moot point, though, as trolley services are definitely profitable (trust me, if it wasn't, Ryanair wouldn't provide one)
Your cabin crew are there anyway for safety reasons, why not put them to use as sales people? Otherwise they're just sitting relatively idle for much of the flight. Not that I wish to discredit the work and important role that cabin crew play: they're far more important than most of us realise... but the fact remains that for much of the middle of the flight, on a routine flight and unless something goes wrong, they don't actually necessarily have that much to do considering the number carried.
The cart may be there anyway! On longer flights with meal services, the airline will already have the cart available for set times. Why not put a few bottles of perfume in the bottom for an extra profit?
Capacity limits. Aircraft aren't always limited purely by space or weight: they're also only certified to carry a set number of passengers due to things like the number of emergency exits. It may be that you can't actually carry more passengers even if you want to
The trolley can fit into space a person wouldn't. A trolley isn't person shaped, and can be stored somewhere near the back of the plane (eg where the fuselage tapers) that you couldn't fit another seat even if you wanted to. Why not use the space for something useful?