Real Madrid is a very big club and has many star players so Modric has to compete with many younger star players there. The failures of Real Madrid in the past season results in his departure from Real Madrid as if they win titles like La Liga and Champions League, he would have been signed another 1-year contract by the club. The departure already happened as did the transfer to AC Milan, now it is a very last chapter in his career begins with this club. He is able to write this chapter as a good one before his retirement too.
The question now according to your comment is, will he be able to win these trophies at AC Milan, most likely No, AC Milan is not in that capacity, and does not have the depth that will be able to get them to win the trophy especially the champions league, they could make a very good attempt at others but not at the champions league even with him present so he could just see there as a place to fo get his retirement and end his career as a football but may begin prospects to be a coach.