Justice Antonin Scalias opinion for the majority stressed that the Court was not casting doubt on long-standing bans on gun possession by felons or the mentally retarded, or laws barring guns from schools or government buildings, or laws putting conditions on gun sales.
2A is about self-defense -- against criminals AND against oppressive government.