'Thank' and 'think' are doublets — to thank someone was originally to think of them with goodwill.
From Old English 'þancian' (to thank, to give thanks), from 'þanc' (thought, gratitude, goodwill), from Proto-Germanic *þankaz (thought, gratitude), from PIE *tong- (to think, to feel). Thanking someone was originally 'thinking of them' — gratitude was conceived as a form of mindfulness, of holding someone in one's thoughts. The same root produced 'think,' making 'thank' and 'think' doublets — two forms of the same original word. Key
'Thank' and 'think' are doublets — two words descended from the same Proto-Germanic root *þankaz (thought). To thank someone was originally to think of them, to hold them in your mind with goodwill. German preserves the connection more transparently: 'denken' (to think) and 'danken' (to thank) are obviously related. Gratitude, etymologically, is a kind of thinking.