And sure, this could be an email (all of the same principles would apply), but a letter makes things official in every sense. It also gives you a prop to take along to the face_to_face meeting with your boss, when you let him or her know that you're leaving.
Your End Game. When you hand in your resignation, it can kick off a bit of chaos__your position will need to be filled, but your duties will also need to be covered until they can replace you. As part of your resignation letter, it's a good idea to convey what your availability is during that transitional period.