I did that once and it ended up being the eulogy at my grandfather's funeral. Unfortunately it got to him an hour after he passed.
Make sure it is heartfelt, make sure you include the good times, memories that will make his family, friends and loved ones laugh. Do not concentrate on the sad times, only the good.
Mine went something like this (as far as I can remember, I chose not to save it so that it would remain between me and him (he was buried with the letter)...
Dear Grampa... It's me, your little ballerina... I was thinking recently about our trip to Alabama for vacation. Remember the 8-track tape player? I was so stuck on Barry Manilow, all you could do was call him Hook Nose. It's been a while, but I want to apologize for the 14 hours of torture I put you through on that trip down there.
It ended up being 5 pages long (on legal paper, front and back), it took weeks to compile. But at the funeral there were very few tears and quite a few laughs.