The royal heir is obviously the future king of the country, the one who is going to rule us all for several decades if everything turns out well, and so he is an extremely important individual. However, his importance and the stakes of his selection go beyond that: upon their coronation, kings get to choose who will be the main patron god of the country for their reign. Therefore, a royal heir represents a potential promise of change for the kingdom, and his selection is extremely fierce.
A new heir should not be selected too soon in the reign of the current king, or that would indicate that the king's current patron god cannot be trusted to protect him—a grave insult nobody with any sense would make publicly. In addition, having to wait for too long for an heir and his patron god to gain control of the country would also only tempt everyone too much to either accelerate the inheritance or attempt to have a new selection by whatever means necessary.
In the end, an heir seems to only be selected when all the gods on the Local Gods' Council agree to do so. Or at least, it is what we have been able to deduce, since all those gods are always in agreement when the start of a selection begins. In practice, selections generally triggered when the current king starts to get old and have health problems.
Many times in the past, the gods had not all agreed quickly enough, and the kings died without an heir. In that case, the selection started immediately and the council was presumably in charge of ruling the country, either by ordering the high priests of each of their Churches around, or maybe even by directly possessing them. The fact that it did not change a lot for the rest of us actually betrays how much the gods already control our lives in usual circumstances.
Once the gods have made their decisions to start the selection process, they will begin courting their chosen candidate—or hurry to find someone suitable. In theory, there is no limitation on who they can choose. In practice, the candidates need to be attractive to the people of the kingdom. Potential heirs need to be young to live until their coronation and then survive for a long time so that their patron god can maximise their time in power. However, if they are too young, they are not going to be seen as incompetent and easy to manipulate and so as a bad choice for the people of the kingdom.
If the candidate are exceptional individuals that are very likely to be selected as heirs, a few gods may even fight to get them as candidate. This is one of the rare time when a mortal gets some influence over the gods, and if they are truly talented, they will even be able to wrangle concessions out of the one they choose as a patron god.
Once all major gods have their candidate, they inform the king that the time for selection has come and who the candidates are, and the king is the one making an official announcement to the kingdom. From then on, the candidates need to charm the commoners and nobility—and those need to use this opportunity to also wrangle as many promises out of them as they can in exchange for their support. All of this is usually done through big tours of the kingdoms and numerous balls and little soirées so as to have time to speak to at least all of the nobility.
The big vote is only supposed to be done by the head of each noble family, however everyone's opinion is supposed to be taken into account. Before the big vote, all the nobles are supposed to consult with the people over which they rule to ask for their opinion. Each village will choose a representative to send to their landowner, who will then also choose someone to speak to the local noble.
Once this has been done, all the nobles gather in the capital and proceed to several rounds of voting with one candidate eliminated at each round until one one remains. All those votes are open and the records public, so that everyone knows who is voting for who and can express their displeasure at it. The commoners in particular do not appreciate when their opinions are completely disregarded, and it is not rare for accidents to open right after the votes.
Once selected, a royal heir in theory does not have any power until the king dies and they can succeed him. In practice, it is best to give them something to occupy themselves and keep them out of trouble and away from the temptation to accelerate their inheritance. They often end up as an army general or a minister in the government.
Royal heirs are always a lot of troubles, from the time of their selection to the long wait until they can seize power. It is a constant succession of blackmail, bribery, and outright assassination. A lot of people make pretty promises and then renegade on them as soon as they can. In theory, commoners have some power, but, in practice, only the most egregious practices are sanctioned by rebellions, and even then, it is always the commoners paying the heavier price, anyway. The recent Pollution War is a perfect example of that.
Most other countries have hereditary heirs, and so we are a bit of an exception with our tradition. The only reason we still deal with all that troubles is because it gives everyone the illusion of a choice and it is great fun for the god themselves, canalise their attention into something semi-productive, and we can sometimes get them to do a few more things for us than they would have bothered to otherwise.