Consummate professionals always seek to leave employers on good terms, regardless of why they are leaving.
A few rules for good resignations.
Be kind and gracious. Express your thankfulness for the opportunity.
Don’t lie but don’t feel the need to share everything, especially with defensive managers.
Watch out for stalling tactics like counter-offers.
They may walk you to the door. This can be disconcerting. Don’t take it personally, even though it feels so.
Here is a polite letter of resignation you can use/modify at your discretion.
UPDATE: There are more excellent sample letters of recommendation here: https://ambassadorgroup.com/2019-7-11-polite-letters-of-resignation/
I am sorry to inform you that I am leaving [Company] effective immediately or in two weeks, whichever is your preference. This was a difficult decision, as working for [Company] has been a positive experience and one for which I am thankful. I have learned a lot here, and have enjoyed working with you. There is no doubt my experience with [Company] has prepared me for greater responsibility. However, I have accepted a position that will provide me with accelerated career growth and is in the best interest of my family and myself. This final decision was reached only after thorough consideration.
In order to insure a smooth transition, I will return all [Company] proprietary information to your office.
I wish continued success to [Company] and to you. Please feel free to contact me after I leave if I can be of further assistance.