Why would a state require citizens to register before voting? Why not just allow citizens to vote using their ID card on the day of voting?
Hopefully someone with more expertise than I have can provide more details but having a list of all electors is in any case useful to ensure the integrity of the process.
Even if you require people to show some ID, you don't want them to be able to vote in several places, you need to know exactly how many people could vote in a constituency, check they are eligible to vote in that constituency, etc. And everywhere I have voted (which includes several countries because as EU citizen I could vote in local elections outside of my country of origin), this means I had to sign in a register or at least that someone checked that my name was on a list.
Requiring voters to register explicitly is a simple way to manage these lists. You could imagine other solutions, especially with electronic voting systems, but, e.g., writing down the details of every person who shows up to vote and then cross-checking those lists after the fact would be much more cumbersome than checking the details of each voter against a pre-existing list.
Also, there are countries where you don't have to register per se, you are either automatically added to the election roll when you turn 18 or the list of eligible voters is based on a (mandatory) population register. But in countries like the US or France, there is no such population register or any obligation to register your place of residence with the authorities (apart from specific purposes like paying taxes) so if you want to vote, you have to register separately.
Incidentally, it's sometimes possible to vote in all polling places in your city or constituency but there are also places where you have to register for a single polling place. It might sound old-fashioned but that's a low-tech relatively fool-proof way to reduce the risk that someone would cast several votes, as the lists can thus be cross-checked well in advance and voting is impossible if you are not on the list.
Additionally to Relaxed answer, there is other reason for registration; namely, that the ID itself is not proof that the person is eligible to vote.
Some cases may be:
People who have lost the right to vote, due to a legal process (either automatically as in some places, or because part of the sentence was the loss of such a right).
Foreign people; even legal aliens are seldom allowed to vote unless they get citizenship. Of course this last one could be prevented if the ID specifies the nationality of the holder.