"how to write an apology letter to your husband?" Here's a shot at it:
"Dear Husband (always a nice touch to use his first name, or maybe some sort of pet name like 'Sweet Lips'),
As we both know, I treated you very badly. I was totally in the wrong when I did or said whatever I did or said. I hope you will forgive me. Also, I have cooked you a delicious meal, bought you a nifty gadget such as a GPS, and turned down the bedcovers.