Actual Legos are fairly cheap. You can get a box of 790 for $60, which is like $0.07 per Lego. The expensive sets are the licensed sets. They pay for that licensing fee somewhere. A Star Wars themed republic fighter tank is $40 with 262 pieces, which comes to about $0.15 per piece.
Definitely some greed in there but when you're a recognized brand with the ability to license you can get away with that because you already have the contracts so nobody can compete.