I'd make it polite and to the point, thanking them for the opportunities that they have offered you. Make sure to leave professionally. I find this a helpful template:
Dear [Managers Name],
Please accept this letter as formal notice of my resignation from [company name] as [job title]. As per my contract I intend to work [x weeks/months], making my last working day [dd/mm/yyyy]. [OPTIONAL: I am flexible on this date should you require more / less time of me].
[Personalise the next bit as necessary] I would like to take this time to thank you for the opportunities I have had whilst working here. I have learned much from my time here.
[Your signature followed by typed name]
When handing it in make sure to be polite and professional. If done right your manager will probably have no idea that this is coming and may react in an unexpected fashion. No matter what happens, remain calm.
If it was me, and everything was cordial between myself and my manager, then I would be saying something along the lines of this when handing in the letter:
Hi, [manager's name], could I have a minute of your time? I'd just like to give you this letter. It's my official resignation.
What you say next depends on the reason for you leaving. If you're just moving on to a better job then something like:
Thank you for all the opportunities I've had here, they've really helped me grow. But it's just that time for me to move on to my next position.
If you're moving because you're unhappy in your current position, exactly why you're unhappy should have been discussed between you and your manager before leaving and this is the last resort so there's little left to be said about it:
Thank you again for all your help, I'm sorry we couldn't work things out but I feel it's time I moved on.
Those two can help you cover most situations. If you'd like help with any specific situation leave a comment.