I think above all animation should have purpose and style.
Some websites have gone overboard and added all the parallax animation they could fit on their website. Elements that swoop in from the right and the left and text that fades in. They lost all purpose and even style wise, they are unnecessary.

Animation should be there to improve on the context, to show the user what is happening when he/she interacts with something.

I could say a lot more on this topic, but there is someone who has said it all already.
You should look at what Val Head has said and written. She has made web animation her expertise and would be the best person to answer your question.

I recommend watching this 45min video:
https://www.youtube.com/watch?v=OqvQhZ0bTYY