This is the 207th most frequent Russian word.
ним
The word "ним" in Russian is the instrumental case of "он" (he/it), meaning "him" or "it" in contexts requiring the instrumental case.
The word 'ним' is used here as the instrumental form of 'он' (he), functioning as the object of the preposition 'с' (with).
Я разговаривал с ним вчера.
I spoke with him yesterday.
The word 'ним' changes to 'нему' here due to the use of 'к', but retains the third-person singular masculine pronoun role.
Мы отправились к нему в гости.
We went to visit him.
'Ним' is instrumental here again, signifying agreement with 'он' in the discussions.