I strongly recommend reading the actual decision, this is one of the topics that they address inside of this.
The claimed absolute immunity only extends to "official actions" made in discharging the responsibilities of the office, although a presumptive immunity (which is an immunity that a court could overrule based on lawyers' arguments that it doesn't apply) extends all the way towards the "outer perimeter" of the president's official responsibility. If things aren't official actions even in this "outer perimeter" sense, then the President doesn't enjoy any immunity according to Roberts' opinion.
And keep in mind that "official duties" in theory involves enforcing the laws that Congress has passed, so it's not carte blanche (except that Congress has given the White House a lot of carte blanche power to enforce various laws however it sees fit).
As for the "why", Roberts' opinion lays out these major statements:
1. The core matter of "why" should be, to try to make a precise application of the separation of powers doctrine. The powers need to be separated along some concrete lines, what are they. The claim Roberts makes is (in my words), if Congress were to pass a law that says "The Justice Department must be independent of the Oval Office," that would be arrogating some of the executive power which the Congress has exclusively vested into the Presidency, and would immediately fall afoul of the separation of powers doctrine. Similarly if they said "The President must under no circumstances send the lawyers of the Justice Department out to maliciously prosecute his political rivals for all their minor offenses," you know, that's a statement about how the laws are enacted and that's a power that simply wasn't bestowed upon Congress. And if all such laws would be void anyway, then the Court fundamentally can't find the President to be violating any law of that sort. So the determination is fundamentally that this immunity comes from separation-of-powers.
In the Constitution itself, Roberts points to the fact that the Constitution doesn't vest the executive power in "the administration" or some such, the power is vested directly in "a President" and they use that power to appoint their administration. The administration is their oyster.
2. Those concerns can be mitigated, renegotiated, reinterpreted by trying to appeal to what the original purpose of the power-grant was. So Roberts states flat-out what the Court's opinion was on the original purpose of the power-grant, and it's twofold.
2a. The power understood by the Framers, consists of marshaling the President's considerable resources towards enacting the laws passed by Congress. Roberts' decision goes to great effort to say that no man is above the law, that not all actions taken by a President-in-office are official actions, and that even among the official actions only the ones that directly pertain to enforcing laws and Constitution are part of "absolute immunity."
2b. But also, the framers of the Constitution intentionally built the executive branch to be "swift and decisive" after the Articles of Confederation produced an anemic executive branch that was unable to rally the States together to fight off the British. Being "swift and decisive" in this sense is almost just as hampered by after-the-fact prosecution as by in-office prosecution, because you are still having to evaluate "hey, if I try to enforce the laws that Congress passed by doing X-Y-Z, is this going to piss off some prosecutor enough to make my life hell after I leave office?" vs the same statement "...while I am in office?".
Of course, some amount of hesitation is warranted -- the President doesn't want to be impeached and potentially removed; and he would like to win another election. But Roberts is saying that the federal courts system isn't one of these sources of hesitation for those "I have these resources, and those laws to uphold, I am going to enforce these laws with such-and-so resources and those laws with those resources" concerns. Not during or after the Presidency, because it's not about "oh I have to go to court today", but rather about "Man, I have to go to Legal and get their opinion on this."
3. It lays out a foundational principle that the separation of unofficial and official actions should be done without any reference to what the President was thinking at the time, and without any reference to any generally-applicable laws. So if the President is doing something that a President could do as part of normal enforcement of the passed laws under normal circumstances, but is doing it for secret nefarious reasons and in a way that if a midrate businessman did so, they'd be guilty of fraud: Roberts says "that doesn't matter, it is still an official action regardless of his reasons and therefore swiftness applies and he's immune." And he outright states that this is for a "slippery slope" reason; the swiftness desired by reason (1) is not actually created if you then generate a legal loophole which says "well let's still have the courts consider these other parameters and maybe we can get the immunity disqualified."
The decision thus applies the absolute immunity to Trump's attempts to get the Justice Department to prosecute the (highly dubious) election fraud that he claimed had happened, and it applies the same immunity to Trump's threats to fire the Attorney General if he didn't do as Trump wanted. It says "yeah, it doesn't matter if you convincingly argue that Trump knew the election fraud was bullshit, and it doesn't matter if firing the Attorney General would have qualified at any other workplace as illegal retaliation."
4. Roberts makes it clear that as part of (2a) above he is not overturning past precedents which have placed presidents subject to the courts' subpoena power, even though that in theory also endangers some sort of "swiftness" of the job. So the judicial branch is kind of in this strange middle-ground position of "We can still demand our questions be answered, but we can't throw you in jail for doing what appears to be your job."
Kind of a strange ruling, but it's not total executive anarchy like you might expect. If Biden were to, say, tell his military "Go arrest the Justices, put them in overnight lockup, see how they like the world they created" there would probably be a strong case that, due to due process guarantees, Biden never had the power to order that and it qualifies as an "unofficial" act for which he enjoys no immunity.
Sotomayor's dissent [1] is a must-read as well. She's more concerned than you are.
The President of the United States is the
most powerful person in the country, and possibly the
world. When he uses his official powers in any way, under
the majority’s reasoning, he now will be insulated from
criminal prosecution. Orders the Navy’s Seal Team 6 to as-
sassinate a political rival? Immune. Organizes a military
coup to hold onto power? Immune. Takes a bribe in ex-
change for a pardon? Immune. Immune, immune, immune.
The claimed absolute immunity only extends to "official actions" made in discharging the responsibilities of the office, although a presumptive immunity (which is an immunity that a court could overrule based on lawyers' arguments that it doesn't apply) extends all the way towards the "outer perimeter" of the president's official responsibility. If things aren't official actions even in this "outer perimeter" sense, then the President doesn't enjoy any immunity according to Roberts' opinion.
And keep in mind that "official duties" in theory involves enforcing the laws that Congress has passed, so it's not carte blanche (except that Congress has given the White House a lot of carte blanche power to enforce various laws however it sees fit).
As for the "why", Roberts' opinion lays out these major statements:
1. The core matter of "why" should be, to try to make a precise application of the separation of powers doctrine. The powers need to be separated along some concrete lines, what are they. The claim Roberts makes is (in my words), if Congress were to pass a law that says "The Justice Department must be independent of the Oval Office," that would be arrogating some of the executive power which the Congress has exclusively vested into the Presidency, and would immediately fall afoul of the separation of powers doctrine. Similarly if they said "The President must under no circumstances send the lawyers of the Justice Department out to maliciously prosecute his political rivals for all their minor offenses," you know, that's a statement about how the laws are enacted and that's a power that simply wasn't bestowed upon Congress. And if all such laws would be void anyway, then the Court fundamentally can't find the President to be violating any law of that sort. So the determination is fundamentally that this immunity comes from separation-of-powers.
In the Constitution itself, Roberts points to the fact that the Constitution doesn't vest the executive power in "the administration" or some such, the power is vested directly in "a President" and they use that power to appoint their administration. The administration is their oyster.
2. Those concerns can be mitigated, renegotiated, reinterpreted by trying to appeal to what the original purpose of the power-grant was. So Roberts states flat-out what the Court's opinion was on the original purpose of the power-grant, and it's twofold.
2a. The power understood by the Framers, consists of marshaling the President's considerable resources towards enacting the laws passed by Congress. Roberts' decision goes to great effort to say that no man is above the law, that not all actions taken by a President-in-office are official actions, and that even among the official actions only the ones that directly pertain to enforcing laws and Constitution are part of "absolute immunity."
2b. But also, the framers of the Constitution intentionally built the executive branch to be "swift and decisive" after the Articles of Confederation produced an anemic executive branch that was unable to rally the States together to fight off the British. Being "swift and decisive" in this sense is almost just as hampered by after-the-fact prosecution as by in-office prosecution, because you are still having to evaluate "hey, if I try to enforce the laws that Congress passed by doing X-Y-Z, is this going to piss off some prosecutor enough to make my life hell after I leave office?" vs the same statement "...while I am in office?".
Of course, some amount of hesitation is warranted -- the President doesn't want to be impeached and potentially removed; and he would like to win another election. But Roberts is saying that the federal courts system isn't one of these sources of hesitation for those "I have these resources, and those laws to uphold, I am going to enforce these laws with such-and-so resources and those laws with those resources" concerns. Not during or after the Presidency, because it's not about "oh I have to go to court today", but rather about "Man, I have to go to Legal and get their opinion on this."
3. It lays out a foundational principle that the separation of unofficial and official actions should be done without any reference to what the President was thinking at the time, and without any reference to any generally-applicable laws. So if the President is doing something that a President could do as part of normal enforcement of the passed laws under normal circumstances, but is doing it for secret nefarious reasons and in a way that if a midrate businessman did so, they'd be guilty of fraud: Roberts says "that doesn't matter, it is still an official action regardless of his reasons and therefore swiftness applies and he's immune." And he outright states that this is for a "slippery slope" reason; the swiftness desired by reason (1) is not actually created if you then generate a legal loophole which says "well let's still have the courts consider these other parameters and maybe we can get the immunity disqualified."
The decision thus applies the absolute immunity to Trump's attempts to get the Justice Department to prosecute the (highly dubious) election fraud that he claimed had happened, and it applies the same immunity to Trump's threats to fire the Attorney General if he didn't do as Trump wanted. It says "yeah, it doesn't matter if you convincingly argue that Trump knew the election fraud was bullshit, and it doesn't matter if firing the Attorney General would have qualified at any other workplace as illegal retaliation."
4. Roberts makes it clear that as part of (2a) above he is not overturning past precedents which have placed presidents subject to the courts' subpoena power, even though that in theory also endangers some sort of "swiftness" of the job. So the judicial branch is kind of in this strange middle-ground position of "We can still demand our questions be answered, but we can't throw you in jail for doing what appears to be your job."
Kind of a strange ruling, but it's not total executive anarchy like you might expect. If Biden were to, say, tell his military "Go arrest the Justices, put them in overnight lockup, see how they like the world they created" there would probably be a strong case that, due to due process guarantees, Biden never had the power to order that and it qualifies as an "unofficial" act for which he enjoys no immunity.