This is a very general question and the answers often vary with period, location, and local traditions.
In countries where there are people of many different ethnic groups, at times those groups can become stratified, with the majority group becoming more powerful and systematically discriminating against minority groups. At other times, ethnic diversity is the result of past conquests, such as in the Americas where descendants of Europeans (Spanish in South America, British and French in North America) imported their own religions and traditions to the regions they were colonizing. In colonial and post-colonial societies, many socioeconomic disparities are the result of colonization, in which the foreign colonizers simply laid claim to lands and resources.
In primitive societies, much of the differentiation between genders depends on a fundamental biological difference, that women can bear children and nurse infants. In such societies, women tend to cluster in activities which are compatible with the need for child care and the exigencies of pregnancy. Because men and women in such societies share similar tasks with other members of their gender, there is a tendency for genders to develop their own customs, behaviors, and even language variants.
In many societies, homosexuals are a minority, and as such have developed various codes of communication which enable them to connect with other gay people under the radar, as it were, of heterosexual society. As with any oppressed minority, they tend to develop their own counterculture as a mode of resistance to heterosexist norms.