See my post before. He was forced out.
EDIT: My post was to say the successful NFL coaches don't leave their current jobs for the NCAA. If they get fired/forced out, that's a little different.
Straight from his Wiki page:
On October 5, it was rumored that Harbaugh would not return in 2015 regardless of that season's outcome, though owner Jed York denied the claims at the time.[133] It has been suggested that Harbaugh, despite his success on the field, was involved in a power struggle with 49ers general manager Trent Baalke starting from the 2013 season onward.[134][135] On December 28, 2014, the 49ers announced that they had mutually agreed to part ways with Harbaugh as their head coach.[136] York claims Harbaugh and the 49ers agreed to mutually part ways immediately after a win over the Arizona Cardinals in the final week of the regular season.[137] Harbaugh, however, later said: "I didn't leave the 49ers. I felt like the 49er hierarchy left me."[138] He further added that the 49ers informed him that he would no longer be the 49ers coach after suffering a loss on December 14, but that he decided to remain as the team's head coach for the final two games of the season because "I wanted to finish what I started—what we started."[139]
Also this article straight from Harbaugh's mouth:
Harbaugh: I didn't leave 49ers, they left me