Earlier quoted context omitted.
They take on the vast majority of the inventory risk, which is the fundamental detail everyone seems to miss. They own what they sell. The complications come from trying to manage that risk - manufacturers who have better products or marketing can afford to pay for prime shelf space which also means it'll move faster.
I don't believe this is true in all cases. Maybe for some products, but at least other commenters here are confirming that some manufacturers refund the grocer for any unsold product. (So, Safeway only pays for the inventory that gets sold.) Seems risk-free for grocers on the products they have those sorts of deals with.
Really the modern world allows many optimizations and creative contracts.