We use “which year” when there is a limited number of choices of years and “what year” when it could be any year.
In which year did France win the world cup? 2018 or 2019?
In what year was the war of independence?
You can see that there is a choice between 2018 and 2019 is the first example that means that we use “which”.
“In what year” is more common when we are talking about any year in history.
“In which year” and “in what year” are common questions for quizzes.
In which year
We use “in which year” when there is a range of years and we need to choose one. This could be obvious like in the example above or perhaps selecting a year in a decade.
In reality, the speaker generally chooses what or which depending on the number of years that he or she thinks are possible. If there are a lot of options, then “what year” is more common and if there are a few options then “which year” is more common.
In which year did Donald Trump win the presidency?
In what year
“In what year” is more common when there is a huge quantity of years that could possibly be the answer. Think about a question that is about history and there are a huge number of years possible.
In what year did Mexico declare its independence?