The reason dates from the time the iconostasis began to grow. The Divine liturgy is meant only for the eyes of baptized Christians in good standing with God and the Church. That is why just before the Creed you hear the exclamation, "The doors, the doors, in wisdom let us attend." It was at that point in very ancient times visitors, inquirers, catechumens, and those not communing or not in good standing left, and then the deacons shut and barred the doors. When the priest elevates the gifts and says holy things for the holy, it is meant.
However. after Christianity was made legal and tolerated and converting became much easier (no threat of persecution), and indeed fashionable in a sense, and catechumens and other's had ceased to be actually dismissed, there was a problem…you still had holy things meant only for the holy, and yet the congregation was full of everyone from open sinners, to lapsed believers, to catechumens to penitents, etc. So the solution was the curtain, and later in some parts of the world, the iconostasis (which began as an altar rail raised to support the curtain and then later solidified and covered with icons). The icons still teach the things embodied in the holy mysteries being celebrated on the other side of the curtain. And a person of genuinely spiritual heart will perceive what is transpiring regardless of the presences of curtains or icons or no. So for those of us who are not yet there, the iconostasis and the curtain cut off the sight of holy things from the unprepared, and the idly curious while the icons instruct the hearts of those who would be made ready and come to the fountain of immortality in repentance to be healed.