When requested by a potential employer, writing samples are a crucial part of a student's application materials. Many employers will use the writing sample as a way to discern the best candidates from the pool of applicants who they have interviewed. There are no hard and fast rules for writing samples except they should be an example of your best legal writing.
Here are some basic guidelines:
First, a writing sample should be your own original work. Be careful of submitting materials that will be assumed to have been heavily edited (e.g. law review articles). This does not mean that you cannot submit a writing sample that has been reviewed by a legal writing professor or an attorney at a law firm where you worked. It is perfectly acceptable to use a writing sample that you have revised and edited. The key is that it includes your own revisions and has not been re-written by someone else.
Second, it should be your best work. Primarily, that means that it should be completely free of grammatical errors and typos. Your best work will also showcase that you are capable of doing the work the job requires. Accordingly, what you submit should be an example of your very best writing and analytical skills as well as your research abilities.
Third, it should be legal writing. Work you have written before law school does not showcase your legal skills to legal employers.
Fourth, be sure your writing sample does not include confidential information. Many upper-level students get their writing samples from documents they wrote during their summer employment. Memoranda that are written at firms or for judges are likely to contain confidential client information, attorney work-product or other content that should not be publicly disclosed. It is always a good idea to redact any information that is arguably confidential (and insert fictitious material) and to check with your former employer to insure it is acceptable even as revised.
Fifth, the length of the writing sample is not as important as its quality. However, you don't want your writing sample to be too long or too short. If a writing sample is too short, potential employers will not have enough material from which to judge your abilities. A writing sample that is too long will be burdensome to potential employers both because it is administratively hard to handle and will be difficult to read in its entirety. That said, it is better to err on the long-side so that employers won't be left guessing about your writing skills. Also, it doesn't make sense to choose an inferior piece of writing just because it is a few pages shorter. Remember, you can always take excerpts from a lengthy document. If you do, just make sure that there is enough context so that a reader can understand it - even if it means including a cover page with a summary of the material that has been omitted.