We don't know if Ancelotti will leave the team, as far as I know, no official statement has been made yet. If the official statement has been made and Ancelotti is going to leave the team, they will need to find a better manager instead. There are candidates for this, but I think Bayer Leverkusen's potential young manager Xabi Alonso could be a good candidate for Real Madrid. Of course, former Liverpool manager Jurgen Klopp is also being considered a candidate, but he could also reach an agreement with another name.
Ancelotti will leave Real Madrid, only matter of time as when he leave, and how will replace him in Real Madrid as well as what is a next destination of Ancelotti like retire his coach career or work somewhere else.
With this bad season, time for his departure comes sooner than expected and likely he will leave very soon before this season ending or shortly after its ending. There is noise about possible replacement coach and a most favorite candidate is Xabi Alonso. He was called as Real Madrid target since the last summer but he decided to stay in Bayer Leverkusen and Real Madrid signed a new contract with Ancelotti. Now things seem to change completely and both coaches will change their clubs in this summer.
Another rumor is Ancelotti will take over a head coach position of Brazil which will be his first nationa team coach position in his career so it is worth to try. He is also familiar with many Brazilian players who are playing for Real Madrid.