To protect ourselves against a tyranical government was the reason that the 2nd Amendment was placed in the Constitution.
I think this view is partially right but also misses something.
All of the Bill of Rights was aimed to limit the power of government, state, local or Federal, to infringe on the rights of the people. All of the original 10 amendments defend the rights of the people against the abuses of government.
The 2nd amendment did two things, it protected the right of the people to have and keep arms as individual citizens and it protected the state run militias (for those states that had them) from being unilaterally dissolved by the Federal government.
The Constitution had bound the "well regulated" militias to Federal and State control. They could not act outside of that control legitimately.