When it was written there was no standing army nor police, so it allowed people to quickly form an army if required and allowed people to defend themselves. These are not as important points as they were at the time. But one that has gotten more important with time (I believe) is that it was also meant to allow citizens to rebel to a "tyrannical government". In other words it was meant to prevent the US to become Russia, North Korea or China - Not without a fight at least.
I also think that restricting guns is not guaranteed to work. If you look at the UK, gun restrictions are pretty recent and there was a time both the US and the UK had freedom of gun ownership. Yet the UK had very few mass-shootings.The UK might still have few mass-shootings even with less gun restrictions.
On the other hand, some countries that have very strict gun restrictions but have higher gun violence than the US (e.g. Mexico).
So the reality is that it's complicated.