Florentino Perez has not only built a strong foundation to make Real Madrid the biggest force in Europe, but he has also made Real Madrid the best team in the world. And talking about hard work, Los Blancos always try to perform well in every season, it's just a shame that the results they get this season are still far from what is expected.
Not entirely sure if he deserved to stay, but not sure if it was needed to send him away neither. I mean he did win 2 league titles and 2 UCL with them, that should be good enough to keep going, and one bad year shouldn't be an issue. So when you think of it like that, it feels as if he should have stayed.
However, reality is that he didn't look like he is going to be better on the long run, they didn't had trust in him that he would be there for another 5 years. Even if you gave him one more year, best case would be he would win again, and then lose again. What they wanted was a younger manager, who is doing a great job and they wanted to see him do a fine job of it as well. If they keep doing that, then they should be fine with Xabi, for a long long time.
Of course, Madrid knows that he is getting old and will leave the club very soon which made them not interested in keeping him. Maybe, his nature is that he loses this season and wins title the next season, but they are somehow not comfortable with him coaching the club anymore. This was why they brought a younger coach who can spend more time to work and solidify the team so that the trophies will keep on coming in.