Shmuel (Meg 7) holds Megillas Esther is not metamei yadayim because it was given b'ruach hakodesh to be read, but not written. The gemara in Shabbos tells us that to discourage the practice of storing terumah (which was assumed to be kodesh) next to kitvei kodesh which caused mice to nibble at the kitvei kodesh with the terumah food, the chachamim were gozeir that handling kitvei kodesh make the hands tamei and hence would cause terumah to be tamei (under the right conditions).
Tosfos cites a number of gemaras that indicate that the megillah must be written - in fact, a braysa tells us later that it is assur to read by heart not from a text. If so, how can Shmuel tell us that the megillah was not given to be written? Tosfos distinguishes between the halacha of kesiva that is divrei kabbalah, and a din derabbanan not to read without a text. However, the Ritva gives a far more compelling answer. There is a difference between simply writing a text for the sake of avoiding the issur of reading by heart and writing to establish a canonized text as one of the kitvei kodesh. Shmuel did not mean to say there was no halacha of writing the megillah - Shmuel meant that even if written, the Megillah does not have the status of other canonized kitvei kodesh with respect to the gezeirah of tumas yadayim.
The Brisker Rav (al haRambam) elaborates on this idea with many other proofs. The Rambam paskens against the majority of the Rishonim and holds that ibud (tanning) of the megillah klaf does not have to be done lishma despite the fact that megillah is called "sefer" and is treated like a sefer Torah with repect to many other halachos of kesiva. Why is the halacha of ibud different? The Brisker Rav explained that the Rambam understood that we learn formal halachos of "writing" from the dinim of sefer Torah, but not halachos of kedushas sefer, as we see from Shmuel's din. The machlokes between the Rambam and others is whether ibud is a halacha in kesiva or is a halacha in defining the kedusha of the text.