Discovery of the law that no Ammonite or Moabite should ever enter the assembly of the Lord ( Deuteronomy 23:3-4) led the leaders to exclude all foreigners from the restoration community. [source][source][source]
There are three explanations for Ruth"s inclusion. The best one, I believe, is that unbelieving immigrants from these nations were those denied full rights. This would explain why Rahab, a Canaanite, and Ruth , a Moabite, became citizens. They were both believers. Another explanation is that the use of the Hebrew masculine nouns, Ammonite and Moabite, refer to males exclusively. A third possibility is that the Israelites simply did not enforce this law. [source][source][source]