Let’s define some terms here. The Torah says that a “ben neichar” may not eat from the korban Pesach. But what’s a ben neichar? The word roughly translates as “alienated” or “estranged.” Rashi quotes the Mechilta that this law applies both to a non-Jew and to an apostate Jew. (A mumar – apostate – is a Jew who leaves the path of Torah to worship idols. Ravshakeh, the Assyrian officer in II Kings chapter 18, was an apostate Jew.) So, the korban Pesach was for Jews only – and not just Jews, they had to be Jews “in good standing!” (Non-observant Jews could eat of it, so long as they hadn’t turned to idolatry.)
The Talmud in Pesachim 3b relates a story in which a non-Jew bragged to Rabbi Yehudah ben Beseira, “Even though it says that no stranger may eat of the korban Pesach, every year I pass myself off as a Jew and they give it to me.” Rabbi Yehudah asked, “Do they give you the fat tail of the lamb?” The man replied that they did not. Rabbi Yehuda continued, “That’s because it’s the best part. If they don’t give it to you, they must know you’re not really Jewish.” The next Pesach, the man asked for the fat tail. However, this part of the sacrifice was offered to God, so the people in the man’s group became suspicious. They checked into his background, discovered he was not Jewish, and the jig was up.
The reason for this mitzvah is that the korban Pesach commemorates the Jews leaving Egypt to become God’s servants. It’s not appropriate – actually, it’s outright hypocritical – for a person who has turned his back on Torah to celebrate the Jewish nation’s union with God. This law applies to both men and women at the time when the Temple is standing.
The Rambam discusses this law in Hilchos Korban Pesach chapter 9. In the Talmud, it is discussed in the tractates of Pesachim (96a) and Yevamos (70b-71a). It is #128 of the 365 negative mitzvos in the Rambam’s Sefer HaMitzvos.