Keep Your Letter of Resignation Simple
Writing a letter of resignation might be an unpleasant task, but there's really not that much to it. In its simplest form, you just date your letter of resignation, say when and what you're resigning, sign it, hand it over, and that's it. Five minutes, and you're done.
Unless you possess the judgment of an attorney and style of a professional writer, don't write much more in your letter of resignation if you wish to use your soon-to-be ex-employer as a reference. There's really no need to explain your reasons for resigning anyway. For one thing, it's really nobody's business but your own. For another, however honorable your reasons may be, it's very hard to strike just the right tone in writing.
For example, if you write in your letter of resignation that you've found a more challenging career opportunity, it implies that you're bored with your current job. If you write that you're having family or health problems, you've just documented that you might be a risky hire. Your words may haunt you down the road, when a potential employer contacts your former employers as references. Your words might also be used as evidence against you, should you sue your former employer for a wrongdoing. For example, if you write that it's been a pleasurable experience working there, then later sue your employer, you might have a hard time proving harm.
In other words, try not to leave anything up to the interpretation (or misinterpretation) of the reader when writing your letter of resignation.