Dealerships don't make a profit on labor cost, so they have to make a profit on parts. They are also liable for any warranty work associated with each order they fulfill so that cost is factored in.
I don't care for dealerships or their pricing myself but we have to stop acting like the dealership is a rip-off just because we can DIY for 1/4 the price at home. Businesses have taxes and overhead to account for in any sale, so it's not an apples to apples comparison.
How does a dealership NOT make a profit on labor cost? The mechanic sure isn't getting 100% of that labor charge! They get a percentage, and then the rest goes to the dealership. If the book says the job is 60 minutes but is actually done in 30 minutes, the dealership and the mechanic are still getting paid their percentage of a 60 minute labor bill.