I think there are people that help you become the person that you end up being, and you can be grateful for them even if they were never meant to be in your life forever.
Being grateful 'for' is exactly right; it shows you can accept the distance you are forced to take from such people, but fully appreciate and bear responsibility for the goodness of the impact they can have on your life by teaching you how to live with who and what you are, and with what life can sometimes be like. There's a bittersweet satisfaction to that...
This. This is where I am at.
Yes I lost a good friend and it absolutely killed me at the time and while I know we will never be part of each other’s lives again I have now reached a place (two years later) where I am grateful for the experience because it did shape me into a better person ultimately