Apple was in really bad shape at the time. MS supposedly gave help in exchange for getting their software (Mainly IE and MS Office) on to Mac's. Although most official sources put the amount of the deal at $150 million, there were rumors at the time that the amount is much higher than that. Frankly with the kind of position Apple was in, MS didn't really have any real need to invest that amount of money, but they still went with that. Many see it as Gates helping by investing rather than MS doing it.
Unlike Balmer, Gates was an admirer of the Apple of the 80's which really focused on building and selling great products like the Macintosh rather than over-hyping mediocre products with marketing like the Apple of today. There was even a video somewhere of Young Gates singing praises of Apple like anything. This may have been one of the factors.