As Mary says (+1), it depends.
If you are writing a Sherlockian Mystery (super-detective gets a tough case), the motive is often hidden until the finale. Figuring out Why the victim was murdered is the entire story.
In the Sherlockian series House (super-detective but jerk doctor), the "villain" is whatever disease is afflicting the patient, and House must figure out what it is before it kills the patient (to sustain suspense, sometimes House fails, or a bad guess kills the patient).
And then in some of these stories, our Sherlock is certain they know who the killer is and what their motive is (e.g. to inherit $millions) but the story is not a "whodunnit" bu a "howdunnit". They have a rock solid alibi!
In other kinds of stories, it is great if you can reveal the motive early. It is interesting when two forces collide in conflict and both of them have good understandable motives. A "scarce resources" story.
In real life, countries fight wars over water resources, both of them need the river to irrigate their crops and drink, the flow is down, and one side must go without. Which will result in untold deaths. Who wins? Should they win?
In post-apocalyptic stories the motives are often clear; both sides have clear and understandable motives we can relate to. They love their families, they love their kids, and their survival depends upon food and shelter -- the same food and shelter the other side needs to survive. A zero-sum game.
In fact there are no "villains", we recognize the dilemma immediately. With only half the resources, we don't survive. We all starve anyway. If half of us don't die, we all die.
The story is not harmed at all by the reader understanding these motives.
Those are extremes. Ultimately the question is, how much interest will be lost in the story if the audience knows the motives of the antagonist?
In a Sherlockian Mystery, the answer is nearly all of it.
In a play about a hero struggling with intentionally harming other innocent people to keep her own children alive, almost none of the suspense is lost.
There is one more type of story in which the villain can have clear motives from the beginning; a "dark side" villain. A sociopathic dictator that is bent on acquiring personal power and ruling with an iron fist.
Her motives are clear. In this case, the story is often "David vs. Goliath", the basis of many "007" stories. Agent 007 knows from the beginning exactly who the villain is and what their motives are (world domination, insane riches), but the story is partly a mystery about how 007 can stop this seemingly unstoppable force.
Again the motives are clear from the start, and knowing that greed and megalomania drive the villain doesn't hurt the story. The story is more about how one lone fearless genius hero (David) with great skills and a few gadgets can stop a villain commanding an army and enormous resources.
Figure out what type of story you are telling, and how early you can reveal the villain's motive without destroying the suspense of the story.
If revealing the villain's motive early doesn't make a lot of difference to your hero (the hero doesn't care why the villain is doing it, the hero will do what she intended to do anyway), then reveal it early, or make it an early dramatic discovery for the hero. For example, in the currently running series La Brea, about time travel, the villain's motive is revealed fairly early -- he invented time travel to correct a mistake he made in his past that cost him his wife and son. And the villain doesn't care that changing that will rewrite a hundred years of the past, including vanishing the hero, the hero's children, and making many others non-existent. The villain believes none of that timeline should have happened anyway!
The villain is motivated by love and heartbreak, the hero is outgunned but motivated by love for his family. In this case knowing the villain's motive doesn't reduce audience interest, it actually makes the story more compelling. It's a "resource" story! Only one of the two timelines can prevail; thus only one side can "survive".