I am pretty new at my work, having only been there for a few months (compared to people who have worked there for up to 10 years) and I felt a little pushed aside during lunch breaks or company parties as the old guys had much more things in common to talk about. However, I got some nice contact with a coworker who is generally not full effort into the work and is the first person to enhance conflicts if there appear any. Yet, he was very nice to me and it helped me feel better as barely anyone else wanted to speak to me outside the obvious work-related stuff.
Recently, someone from HR planned a short meeting with me and the pure fact she planned it ahead instead of just straight up approaching me seemed like the matter is somewhat serious. So we went to the conference room and after some initial chit-chat she suggested that I "should be more careful choosing company amongst coworkers". I did not understand at first but then she pointed out that I started hanging out and generally getting closer to the guy mentioned in the previous paragraph. She told me that this guy is generally poorly viewed by the management because of his low engagement to the work stuff and his propensity to throw some mildly offensive jokes that can cause him to get sued by anyone who feels offended. At the end of the meeting, she said that I seem to be a promising candidate to get promoted in the future and therefore it is not advised I am associated with the guy who might receive a termination of employment soon.
The last part sounded a little bit like a threat to me. I know for sure the HR really dislikes this guy and I can somewhat understand her (yes, his jokes are really out of place every now and then). However, I can't seem to find out why staying in good relation with him (as I have been trying with anyone else with poor results) could hurt my career. What should I do in this case? Should I comply and reduce contact with the said coworker to avoid any potential inconvenience? And also, what could the possible motives of the whole matter be? Is HR trying to separate the guy from the other colleagues to convince him to quit himself or is she genuinely trying to protect me?