This question already has an answer here:
We often get "HR is not your friend" at Workplace. What does this phrase mean? What are the motivations and incentives of Human Resources (HR) that might set it at odds with an employee?
I think a canonical answer here would be useful, especially for new entrants into the workforce, and for anyone unfamiliar with the phrase and coming across it here.