The 2nd amendment seems to me to have a pretty clear purpose, its to prevent the states from disarming the citizenry because at a time when the federal government had no standing army the citizenry would have to defend the federal government.
So its purpose is to limit the states ability to ban arms, that isn't a limit on federal authority though.
The other reasons, like self-defense, hunting, etc., are good reasons but they aren't part of the Constitution. The recent ruling is just judicial activism, some judges like those reasons so they just say they're there even though they obviously aren't.