there are simply planetary affairs which need to be handled which have absolutely nothing to do with the Federation.
Affairs would always be ideally handed at a specific level of hierarchy tailored for each affair. But all hierarchies in reality consist of only a limited number of levels, forcing people to go higher up or lower down than they would prefer to get their voice heard.
Setting a hierarchy level at "one planet" is awfully arbitrary. Some planets in Trek are self-contained units that only do minimal trade with each other, true - but OTOH we hear of mining worlds or agricultural worlds that apparently do major trade and not much else. The need for a President of Earth might not be particularly pressing, whereas mankind would have a desperate need for a President of Antarctica for the resources inherent in the location, and for a President of Sol, Alpha Centauri and Barneyworld for the economic unit defined by these three key systems.
Whether either of these local levels of government would be relevant to the defense of planet Earth is anybody's guess. Government hierarchy levels in general do not
go hand in hand with the way the military defending said government organizes its forces; there's no military equivalent to a Mayor or a Senator, say, no city-level or 1/Xth-state-level defensive unit. Why should the existence of a President of Earth be necessary for the defense of Earth?