The sarbat khalsa is the whole Khalsa in assembly. It is summoned at the Akal Takht in Amritsar, the seat of temporal authority that Guru Hargobind established facing the Harmandir Sahib, and its resolution, a gurmata, is taken in the presence of the Guru Granth Sahib and binds the entire community.
Its working period was the eighteenth century. The Sikh community was under Mughal and then Afghan pressure, organised into misls, fighting bands with their own leaders and territories, and it had no state and no central executive. The sarbat khalsa was how such a body acted as one. The misls assembled at Amritsar, conventionally at Vaisakhi and Diwali, put the question before the Guru Granth Sahib, and took a decision that held across leaders who otherwise answered to nobody.
The theology and the practice fit together exactly. Sikh doctrine holds that the Guru is present in the scripture and in the assembled community, so a decision taken by the whole panth before the scripture is not a majority vote but the Guru's decision. That is what gives a gurmata its force, and it is why a gurmata is distinguished from ordinary resolutions and reserved for matters touching the community as a whole.
The institution lapsed under Ranjit Singh, whose kingdom had no use for an assembly that could overrule it, and did not recover its old function under colonial rule, which built other structures instead.