The oldest instructions that survive are restrictive, and they are restrictive for a reason that is not about worthiness. The Didache tells the assembly to let no one eat or drink of the eucharist except those baptised into the name of the Lord, and Justin Martyr, writing in Rome in the middle of the second century, says the same. Catechumens were present for the readings and the sermon and were then dismissed by the deacon before the eucharistic prayer began, a break so structural that both the eastern and the western liturgies still show the seam where it was. The logic is that the meal is the act of a body, and that a person who has not yet been joined to the body cannot perform its act.
Reformed practice produced the most elaborate machinery for the same idea. Communicants were examined by the elders in the days before a communion season and issued with a small metal token, which they handed in at the table; no token, no admission. Before the elements were distributed the minister fenced the table, reading aloud the categories of person who should not come. The custom was not primarily about excluding strangers but about the congregation's own members, and it rested on the warning in the eleventh chapter of First Corinthians about eating and drinking unworthily.
Roman Catholic and Orthodox practice restricts the table for a different reason again: not preparation but communion itself. Receiving together is held to state that a shared faith and a shared church order already exist. Where they do not, the statement would be false, and the closure is a refusal to say something untrue rather than a judgement on the person turned away.