1. Discredit Hillary.
2. Discredit Bill.
The reason for the second line of attack is that people may remember how well Bill Clinton ran the country, and vote for Hillary because they think she will be a similar president. So Obama peppers his speeches with lines like, "Ronald Reagan changed the trajectory of America in a way that... Bill Clinton did not" and "[small towns] fell through the Clinton Administration and the Bush Administration". Obama tries not only to discredit Bill Clinton's presidency but also to paint Clinton's eight years in the White House as no better than the current Bush presidency.
Voters might very well associate Hillary's potential presidency with Bill's past presidency; I don't know. It seems clear to me that Hillary would be a very different president from Bill... so perhaps part of the reason for attacking Bill is to instill fear that he will have a large influence and repeat his past "mistakes." (Prosperity, peace and social justice... hmmm, what a mistake.)
The unfortunate consequence of Obama's strategy is that Bill Clinton's legacy as president is being eviscerated. If you read the Huffington Post, you'd think Bill Clinton was the worst president ever. Today's HuffPost front page has a screamingly large headline, "Bill Clinton Suggests Young Voters are Foolish". The article, itself headlined "Bill Clinton: Older voters too savvy to fall for Obama" contains no quote from Bill about younger voters being foolish. What Clinton is quoted as saying is, "I think there is a big reason there's an age difference in a lot of these polls. Because once you've reached a certain age, you won't sit there and listen to somebody tell you there's really no difference between what happened in the Bush years and the Clinton years; that there's not much difference in how small-town Pennsylvania fared when I was president, and in this decade."
He's saying that older voters were there and remember what happened, not that younger voters are incapable of understanding.