I would avoid approaching this from a legal standpoint. Plenty of people on FT have indicated that the EU law is muddy, so, don't get stuck in it.
You can approach it from a service standpoint.
First of all, I would call BS on that line that T5 only has 3 gates that can accommodate a 747. I've seen 747's from all over the world lined up at T5. T5 is designed for the wide-body long-haul aircraft. Also, it wasn't like your flight arrived by surprise. The ORD ground crew had 9 hours to have a gate ready for your flight. And they have 21 gates to choose from.
You can contact UA with the issue and probably get about 2,500 miles for your inconvenience. But, the legal approach will be more stress than dealing with the 5 hour delay.