The Talmud (Gittin 45b) says:
תני רב המנונא בריה דרבא מפשרוניא ס"ת תפלין ומזוזות שכתבן אפיקורוס עובד כוכבים ועבד אשה וקטן וכותי וישראל מומר פסולין שנאמר וקשרתם וכתבתם כל שישנו בקשירה ישנו בכתיבה וכל שאינו בקשירה אינו בכתיבה
R. Hamnuna the son of Raba of Pashrunia learnt that a scroll of the Law, phylacteries and mezuzoth written by... a heathen, a slave, a woman, a minor... are disqualified, since it says. And thou shalt bid them … and thou shalt write them, which indicates that those who are subject to 'bind' may 'write', but those who do not 'bind' may not 'write'. (Soncino translation)
In other words, the Talmud derives from the fact that the primary example of ritual writing is juxtaposed (in the verses in Shema) to the commandment of Tefillin, which only Jewish adult free men are obligated in, that ritual writing for a Torah scroll, Tefillin and Mezuzot (the Mitzva objects which can be created by a specific writing process) must be performed by Jewish adult free men.
(As noted in the answer there, she can write books of Tanakh, just writing the five books of the Torah wouldn't create a "Torah scroll" but rather something more like a Chumash, just like her writing the text of a Mezuzah wouldn't create a Mezuzah but rather just an object that could be used to read Shema from or something. The exclusion above is from the ability to create those three Mitzva objects, not from writing itself.)