Deuteronomy 23:2

A bastard shall not enter into the congregation of the LORD; even to his tenth generation shall he not enter into the congregation of the LORD.

The Hebrew word for congregation or assembly is qahal, which the Greek translation renders ekklesia or ecclesia, the same word the New Testament uses for congregation or church, showing that God's congregation in earlier ages and the church in later times are the same called-out people, so that membership in the congregation is practically the same as church membership now.
The word translated bastard probably refers specifically to the offspring of incest or of a marriage forbidden by the laws of affinity, rather than to all children born outside marriage.
The exclusion belongs to entry into Israel's assembly under the civil and legal regulation of the Mosaic theocracy, given to Israel alone as a typical people. It belonged to an ancient congregation of one blood and nation with rules adapted to that people, which has not been placed upon the world itself and is not necessary or practical in the great world.

Being shut out of the congregation means being denied the privileges of citizenship among God's people, including holding office. The congregation in view is not the whole people but the recognized ruling body, which had to be composed of men who in outward appearance typified perfection. The exclusion keeps godless persons from coming in as rulers over God's people and keeps persons with defects from being held in contempt.

The verse does not deal with salvation of any sort, the kingdom of God, heaven, or being lost, and does not decide whether a child born out of wedlock can be saved. Its physical, national, and other restrictions are not operative now because they were symbolic of spiritual things; every moral principle that obtained then is still binding now, but national legal exclusion is not. Illegitimate children, including children of unknown fathers and children born through adultery under lax divorce laws, can be saved and are embraced by God's promises of eternal salvation. Whosoever will may come through being washed, sanctified, and justified in the name of the Lord Jesus Christ and in the Spirit of God, for God is no respecter of persons and will not hold any soul responsible for what is not that soul's fault.