Survivor is a game whose fundamental rule is that people are voted out by other players. It is often inevitable that a particular person will go since there are normally enough people to ensure that this happens. To add some spice to the game, the immunity feature is there to give people the incentive to work hard to earn guaranteed survival for another day. There is thus a purpose for it. Immunity gives the "stronger" players a better chance, though of course as a game of Survivor, the best way to win is to avoid the vote and not need to depend on it.
The Survivor game starts off with tribal immunity challenges. A tribe would normally want to win these in order to ensure that they stay in the game at least a little longer and the other tribe is burdened with the problem of voting out one of their own. "Weaker" players tend to get eliminated in this phase as the thinking dictates that the tribe has to be strong so that their chances of winning immunity are as high as possible. Unlike Tengaged Half-Survivor, completely one-sided contests are not too common, as the tribes are made as "equal" as possible. If not, the game would be ruined and undeserving players could go far without any effort.
Later on, there are individual immunity challenges which are generally won by the "stronger" players. These are highly desirable for those who are under threat, or who want to prevent someone else from winning them. Idols obtained this way are public knowledge, so no one will waste a vote on these people. These affect dynamics in the opposite way compared to the tribal immunity phase - a strong player with the potential to win many challenges might attract votes to avoid this situation.
Public immunity is irritating enough for those who want to vote someone out but cannot. An insidious version is hidden immunity, which though termed "hidden" is sometimes public knowledge. Survivor has had three types of hidden immunity, of which the first was really delayed public immunity, the second too powerful, and the third a reasonable balance. The reason for hidden immunity is basically the same - to reward those who endeavour to obtain it.
Hidden Immunity I was a slightly stronger variant of the standard public type that allowed the bearer to keep it and save it for later. As it required the bearer of the idol to play it before the votes were cast, it had little surprise value since no one would waste a vote on him. It was introduced in Guatemala and was played by Gary to good effect. But it would generally not be so useful for an alliance since the opposition could always redirect their votes to a bearer's ally once they see that they cannot vote against him.
Hidden Immunity II replaced it just one episode later. Unfortunately, it was hideously unbalanced as a game mechanism. In Cook Islands, Yul found it and became unstoppable. It allowed him as the bearer to play it after the votes were revealed, which he would obviously do if he found himself on the wrong end of them. Unless the opposition was willing to bite the bullet and force him to use it at the risk of one of them being voted out, he would stay on all the way, which he did. It was just too easy. After two episodes, it was replaced.
Thus Hidden Immunity III was devised as a balance between I and II, and has stayed ever since. The bearer decides whether or not to play it before the votes are revealed. If there any votes for him, they are wasted, and the idol would be well played if these votes would have evicted him. Otherwise, the idol would be wasted if it was not needed after all. On the other hand, the idol bearer risks being blindsided the opponents could attempt to vote him out secretly. While they might tell someone without an idol that he was sure to go, they would obviously not say this to someone who had the idol. There is thus some spice added into the game, and there have been instances of unsuspecting idol bearers being voted out. In one famous case, James (China) even had two idols.
Another consequence is that a minority alliance with an idol could survive against a bigger one. Under normal circumstances, a simple majority vote eliminates someone in the smaller group, and the process can be expected to continue. But with an idol, the bigger alliance has to have at least twice as many votes as the smaller one to allow for half their votes to be wasted on someone who used the idol, but the other half to count against someone without it. In Heroes and Villains, Tyson was famously voted out with his side having 6 against 3 because he was tricked into wasting a fourth vote on Parvati, leaving Russell with only two votes and him with three.
So we can see that immunity is in Survivor for a purpose: to help the "stronger" players to get better placings than "weaker" ones, which would be ideal. Public immunity is a straightforward rule that clearly debars players from voting out a particular player, but hidden immunity is an insidious version as it reveals (too late) that this player could not be voted out.
Immunity should not count for too much, however. Too many hidden idols appeared in Survivor Heroes and Villains, and without them Russell's alliance would not have done so well. After all, Survivor is not a talent contest, but one of strategic voting one to oust the threats. A person who wins due to not being considered for votes in tribal council would generally be considered to have played well. It is a little questionable, though, to consider someone to deserve to win if it was due to lots of immunities. All elements of any game need to be balanced, and this goes for immunity too. As long as it is a twist to make the game exciting by providing some uncertainty, it has succeeded. But if it becomes invincibility, it has failed. This is the case in Tengaged Half-Survivor, unfortunately, which allows tribes to grow too strong, thus going against the spirit of Survivor.