the purpose is to stimulate the interest of a potential employer to grant you an interview.
The resume should be written first before you write the letter of application because you will be able to organize your thoughs about yourself and see yourself in relation to the job you are applying for.