Yes, it is legal to watch anime online. But ensure you are using any official or legit website for it. Watching animes from websites with no copyright of it is illegal.