The former AC Milan boss spent five successful years in charge of Juve prior to his exit at the end of last season.
After Zinedine Zidane left Madrid following the 2017-18 campaign, the club had short spells with Julen Lopetegui and Santiago Solari in charge.
Allegri was one of the other options pursued by the club and the Italian thanked Madrid president Florentino Perez for his interest at the time. Madrid ultimately turned back to Zidane in March 2019.
“Two years ago, there was contact, but nothing came of it because I had a contract with Juve,” Allegri told Marca about Madrid’s interest. “Furthermore, I had a strong moral commitment to the club and its fans.”
Allegri was asked what he likes most about the work Zidane is doing at Santiago Bernabeu, with a La Liga title on the horizon as the delayed 2019-20 season nears its conclusion.
“The strength he has had in finding the indispensable balance of a team so full of class and talent,” Allegri said. “For me, the positioning of Casemiro has been a tactical masterclass from Zizou.”
Discussing his own future, Allegri continued: “I’ve been charging my batteries [since leaving Juve] and enjoying time with my family and my city, Livorno, with my lifelong friends.
“I don’t really care [if my next job is in Italy or abroad]. I’m looking for a club to share a project with and which has the ambition to compete to win.”
When questioned over whether he would like to coach in La Liga, Allegri added: “Who in their right mind would say no to this question? No one.
“There is more pleasure of playing in La Liga, no matter the result. After conceding a goal, the team keeps playing as if nothing has happened. In Italy, on the other hand, there is much more love and attention for the details of the game and tactics. The brain almost always wins out over the heart, in general.
“[Italian football is more difficult] because of what I said before. The player doesn’t have much freedom to enjoy themselves in a purely instinctive way and this sometimes makes it difficult.”