Being in the government often leads to reduced popularity.
Consider the options:
No early election. RN popularity continues to rise, and they take the presidency and parliament in 2027. Result: Complete power for 5 years.
Early election. RN wins, and forms a new government. While being the ruling party, they lose in popularity and lose the elections in 2027. Result: limited power for 3 years.
To me it seems quite clear that option 2 is preferable to 1 for Macron.