If Bayern Munich's only goal is to win the Champions League next season, they will want to have Ronaldo in the squad. And if they have long-term plans, they will definitely look for a young player to replace Lewandowski. However, if Lewandowski leaves Bayern Munich this season, the Munich management may offer to sign Ronaldo.
Of course, it may be better for the team to make a deal with a young football player that will last for years. But I don't think he will retire yet if Ronaldo plays for a team he's happy with. He still works hard and has a pretty strong body, physically like he's in his early 30s. So he can continue to play.
With this discipline, I think Ronaldo can still play very well in his 40s

Regardless how good a player is, he can't do anything if he doesn't find a support from the other players in the team. CR7 did quite good in Juve and ManU but look how bad these teams were in these seasons although having good players. Many fans criticised the way CR7 is playing and blamed him for the way the team was performing.
Anyway it would be better for Bayern to find a younger talent. Having CR7 won't guarantee anything imo.