The idea (how to organise society if you won’t know your position within it) is discussed extensively by philosopher John Rawls. It is called either the “Original Position” or “veil of ignorance” thought experiment. The idea itself goes a little further back, as discussed in the linked wiki article.
https://en.m.wikipedia.org/wiki/Original_position