Technically, Luxembourg isn't a tax haven... but it does have some advantageous tax, as does Ireland.
US companies use Luxembourg as VAT (sales tax) is only 15% so they use this for e-commerce, which means when selling to consumers only 15% is nabbed in sales tax, opposed to say 21% if they were based in Ireland. Which is a polite way of saying they have reduced their (sales) tax liability.
Now, Ireland is used by US companies as they are 'tax friendly' in that to encourage US companies to locate there they only impose something like 5% corporate tax (on profits). The cherry on the cake is that when this profit is transferred to the parent US corp then its not taxed again (I can't remember if this was done as a double-taxation treaty of as a specific get out in the US tax system)
So, now you know why people like Apple sell from Ireland but specifically base their iTunes service in Luxembourg.