James is from a rich pure-blood family, and ze's very popular, so ze's basically at the top of wizarding society. Lily is not only a muggle-born, but also makes no attempt to hide it or conform to wizarding social norms. At any moment, people could start making fun of James for zir obvious interest in Lily.
So, to avoid that, James constantly asserts zir dominant position by attacking Snape, who's unpopular and, not coincidentally, has a muggle parent.
Lily and James actually like each other, but their relationship is slightly cramped by James's refusal to acknowledge zir pure-blood privilege.
It would be nice to have more scenes showing what Lily and James's relationship is like when they're not arguing with each other, but, well, the original books didn't include much of that either.