How popular did you think fantasy was? It's not considered a niche genre for nothing. Boardwalk Empire was watched by more people because it's a genre that appeals to more people. That's all there is to it.
Walking Dead costs exactly $0 extra on your cable bill to watch. HBO? About $10/month more. That right there is going to put a big dent in the ratings.
And by what logic does spending a lot more money on a second season recoup your expenses from the first season? That's the most backward logic I've ever heard. If anything, if they thought the ratings were bad, they would have just let this season wrap up and never mention it again.