So in ear and over ear are barely comparable in terms of which is better quality, but they do have their own uses.
Over ear generally get you better sound for the price. The 300 dollar HD650 will probably sound much better than any 300 dollar iem you can find. This is because the smaller the headphone, the harder it is to get good sound out of such a small unit, and the higher the production cost is (probably due to R&D and the need for specialized gear to make such small units).
Over ear open backs are also likely to sound much more natural and spacious. If HiFi is the pursuit of the most natural and lifelike sound possible, than open back over ear headphones are most likely to offer that.
IEMs on the other hand tend to offer better isolation because they plug the ear canal. They are also much more portable and tend to be easier to drive from mobile devices. Depending on the type, they can also be much more comfortable due to reduced weight.
It completely depends on what the headphone is needed for.
Want big sound but need to block outside noise? Full size, over ear, closed back.
Want convenience and portability? IEM.
Want natural and spacious sound? Full size, over ear, open back.
Want big sound, but need to travel a bunch? Closed back, portable, over ear. (Perhaps something that folds)
If I had to pick a side and claim that one type is "better" then I'd say that over ear, open backs are the best by far. They tend to reproduce music in the most accurate and natural way