Francesco Caputo opened the scoring for the hosts after 28 minutes as Juve's unbeaten record in Serie A looked under threat.
But Ismael Bennacer's foul on Paul Dybala allowed Ronaldo to level nine minutes after half-time.
Empoli, who were promoted from Serie B as champions, held firm but there were powerless to prevent Ronaldo firing home the winner with a blistering strike from 25 yards.
Ronaldo's double extends Juventus' lead at the top of the Italian top flight to seven points ahead of Napoli's clash with Roma on Sunday, and takes his personal tally to seven since his summer move from Real Madrid.
“I told the lads, this was a game we had to win, it didn’t matter how well or badly we played," Allegri told Sky Sport Italia after the 2-1 victory.
"The goal was a moment of magic from an extraordinary player and it’s something kids will try to copy in the schoolyard.
"It’s much easier to get kids passionate about that rather than explaining tactics to them.
“I continue to maintain there is too much theory in Italian football schools and it pains me to see kids go to training and not even enjoy themselves.
"We’ve got to focus on the simple things in life first.”
However, Allegri found no fault with his side's initial approach, and praised Empoli for showing great heart throughout the 90 minutes.
“The team had started with the right approach, but after 10 minutes we slowed down the tempo of our passing and allowed a few too many Empoli counters,” he added.
“Empoli are tough to play against, as they had one centre-forward, two trequartistas and the wingers that had pace, so we had to be wary of the counter and that is how they scored the goal.
“In the second half, we created many chances and deserved the victory, but we have to tip our hats to Empoli for being so well-organised and impressive.
“I left at the end because there were five seconds to go and we would either win or equalise, there was no other option.”