Any other details can be worked out through discussion, including how much notice will be given and when you'll get your last paycheck. If you are forced to take legal action for any reason, or if the company sues you for, say, stealing information, anything you put in your letter can be used against you. Don't explain, don't complain. That's another article, and another discussion to have with your boss long before you start pursuing other jobs. Likewise, your resignation should not be a forum where you explain all that's wrong with the company.
Explanations lead to complaints, and complaints can lead to problems.
Even if the HR department wants you to share all your thoughts and feelings in an exit interview, the time of your departure is not the time for you to help fix what's broken at the company. Such meetings can be helpful under the right circumstances, but in my opinion this is no time to open your heart and tell all. I'd politely decline. If HR isn't aware of any problems that may have led you to resign, they're doing too little, and they're asking too late. Anything you say could hurt you.