To the contrary, it's actually extremely hard.
When I order, I probably get something incorrect ~10% of the time. Whether fine dining or fast food.
To deal with life-threatening allergies, you need to get that error rate down from 10% to, what, 0.000001% or something?
You're literally asking for hospital- and pharmacy-level procedures, controls, and training. Which would make restaurants far more expensive and there would be far less of them.
Not impossible, but yes extremely hard, when servers mix up orders and cooks mix up tickets and runners mix up plates and tables.