The main philosopher who spoke of this was John Locke. This is the idea of the social contract. According to it, if the ruler is unjust then the people can change him or her. This was one of the key aspects of the democratic principles that the founding fathers of the US adopted.