Keep it short and simple. Even though most people leave their jobs because they can't stand a coworker or the job itself (or both), don't place blame, rant or burn bridges. It is somewhat expected you list a reason for leaving, but keep it generic or neutral, like wanting to spend more time with family or pursuing 'other opportunities'. It's usually bad form to mention specifically what your next job is if you already have one.
Set a date, typically at least two weeks in the future, and state this as your last day.
If it is up to you or your responsibility, list the individual who will be assuming responsibility for your projects or duties after your departure. Always be open to training your assigned replacement until your last day.
Even if you hate a job or someone you work with, serve out your listed time until your last day. Leaving earlier can mean bad references in the future, and possibly even getting blacklisted from coming back to work at this place. It might seem like you never want to return, but maintaining professional connections and networking is always a priority.
Stay calm and classy until your last day arrives. This shouldn't actually be too hard since you have a dwindling amount of time remaining until you no longer have to work there.
Make sure to say something appreciative of the place you work for, and thank them for the time you had there.