"it" refers to the community which those people have formed.
The full quote of paragraph 95 from Chapter 8, "Of the Beginning of Political Societies", available here, is:
Men being, as has been said, by nature, all free, equal, and independent, no one can be put out of this estate, and subjected to the political power of another, without his own consent. The only way whereby any one divests himself of his natural liberty, and puts on the bonds of civil society, is by agreeing with other men to join and unite into a community for their comfortable, safe, and peaceable living one amongst another, in a secure enjoyment of their properties, and a greater security against any, that are not of it. This any number of men may do, because it injures not the freedom of the rest; they are left as they were in the liberty of the state of nature. When any number of men have so consented to make one community or government, they are thereby presently incorporated, and make one body politic, wherein the majority have a right to act and conclude the rest.
Locke isn't talking about a united community that contains everyone, but only some subset of people, while the rest remain "in the liberty of the state of nature". Therefore, there are still people not included in this "unite[d] community", and it is they against whom the community members may need security. Looking at the relevant part of your sentence again:
agreeing with other men to join and unite into a community for their comfortable, safe, peaceable living one amongst another, in a secure enjoyment of their properties, and a great security of any, that are not of it.
(Emphasis mine, to show clearly what the "it" refers to.)