Why did Philip IV defeat the Pope in 1303, but Emperor Frederick II Staufen could not do this in 1230-1250?

Frederick II Staufen, unlike Philip IV of France, was not a national king, since there was no people-leader in the Holy Roman Empire. Frederick had a solid foothold only in southern Italy, where he had a bureaucratic apparatus at his disposal.

Remember: The process of learning a person lasts a lifetime. The value of the same knowledge for different people may be different, it is determined by their individual characteristics and needs. Therefore, knowledge is always needed at any age and position.