Ex-Scotland international Caldwell, 32, played 111 games for Wigan and was part of their 2013 FA Cup-winning squad.
He retired earlier this season because of a persistent hip injury.
Caldwell is Wigan's third manager of the season, following Uwe Rosler and ex-Cardiff boss Mackay, who was unable to halt the club's slide during his five-month reign.
Wigan are in danger of suffering a second relegation in three seasons.
The 2-0 home defeat by Derby left the Latics 23rd in the Championship and eight points from safety.
Graham Barrow, a long-serving member of Wigan's coaching staff, will assist Caldwell, while Eric Black and Mike Pollitt will serve as first-team coach and goalkeeping coach respectively.
"I've made no secret of the fact I wanted to move into management when the time was right," Caldwell told the club website.
"I didn't expect that to come along as quickly as this, but in football you need to take opportunities when they arise.
"I am honoured and excited in equal measures to take charge at the Latics, where I have shared such incredible memories over the past five years.
"We are in a really tough place at the moment, but we will approach the next five games with only one thing in mind, to win. After that, we will assess where we are and move on."
Wigan chairman David Sharpe said it was an "appointment for the long-term", adding: "After a meeting with him on Monday and discussions all day on Tuesday, Gary was the only candidate we considered because we are so convinced of his qualities.
"He knows who we are as a football club and shares the same football philosophy. He is a natural leader who commands respect from everyone around him.
"People will talk about his lack of experience, but every young coach is in the same place. There are many examples of young coaches being given opportunities and being successful."
Caldwell will take charge of Wigan for the first time at Fulham on Friday.
The game see Wigan fans offered free travel to the Capital.
"We have a huge five games ahead of us and we will keep fighting to stay in this division, starting on Friday," said Sharpe.
"We need the supporters to come to London and back the team.
Championship table Wigan play fellow strugglers Fulham, Millwall and Brighton in their next three games.