The answer is: To prevent politically-motivated and frivolous prosecutions.
All Presidents need immunity. Prosecuting Former Presidents could easily become the norm here, as it is in Failed States. Don't think it couldn't. How many people here would love to prosecute Bush 43 as a War Criminal? If that happened, what President would have the stones to, say, arm Ukraine?
America needs its Presidents to have immunity, in order that we don't become more like Panama or Chile.
Would Richard Nixon's prosecution have been "politically-motivated" or "frivolous?"
Friviolous, yes. The harm that could have come to the Nation is something that people did not appreciate now. It is a feature of Banana Republics and Failed States, and it is a feature that those who are concerned about party, but not country, will not be able to leave alone if it becomes a norm.
Would prosecuting Bill Clinton for perjury have been "politically-motivated" or "frivolous"? He did commit perjury, and he was disbarred for it. But I do not think that it would have benefitted the nation to prosecute either Nixon OR Clinton for what they did.
Nixon broke the law and members of both parties were prepared to impeach and remove him from office. I struggle to imagine any worse harm that can cause a nation than the notion that its leaders are above the law, which is exactly the precedent that was set by Ford's pardon. Watergate and the ensuing pardon shook Americans' faith in government more than anything else in recent history. You should know that better than most people here.
Prosecuting Clinton for perjury may have been politically-motivated but it wouldn't be frivolous. In an ideal world, he would have been prosecuted for rape, which is a worse crime than perjury, but by the time that allegation came out it had been too late. At the very least, he also should have resigned for having an inappropriate relationship with a subordinate.