The above answers are good, but have unfortunately confused some of the concepts in the theory, I will do my best to explain.
What we are assessing is how does one behaviour evolve, links with cooperation and altruism are applications of this. The process of selection in evolution removes the the worst individuals from the gene pool, thus those with comparatively good genes survive to reproduce. With physical traits these mechanisms are well understood, with behaviour there are still multiple theories which have not been concluded but our understanding of them is reasonably complete.
Inclusive fitness is the combination of direct and indirect fitness, direct being your personal fitness, indirect being fitness gained from others. In general this is measured in terms of reproductive success (RS) (the number of offspring you successfully raise to reproductive maturity). Out of this understanding came Hamilton's Rule:
r.b > c
Where r is the relatedness, b is the benefit & c is the cost. In this scenario the cost is a reduction in RS, the benefit is a gain in RS. Benefits are multiplied by the relatedness to the offspring. In normal diploid organisms (Gets DNA from both parents) you are related by 0.5 (half from mother, half from father), but only related to your brother/sister's offspring by 0.25. Thus, if you have two children you have a direct fitness of 1, if your brother has two children you gain an indirect fitness of 0.5. Thus, you would prefer under normal circumstances to have your own children rather than raise your brothers.
Altruism is suffering a cost for someone else's benefit, @Winawer mentions the greenbeard theory, which rests on the assumption that if you can tell someone has the same genes as you then you know that you are related to them in someway and this will be on average be greater than to any other individual. Altruism is a behaviour, defined above, and not a specific action like giving up your own reproduction, thus it is a part of cooperation and not separate from it.
It is true that there are different forms of altruism however these are all just perspectives pertaining to the same theory. ALL behaviour is selfish, reciprocal altruism is just an example of this. Reciprocal altruism, is "If you scratch my back, I'll scratch yours" (You need help now, I may need help in the future), it is altruistic because you suffer a cost for another's benefit but it is selfish because it is still in the individual's interest to help. This is where prisoners dilemma comes in, this is basically asking the question "how do I pick the most optimal situation in this scenario?"
For simplicity, it is generally ill advised to study behaviours in humans because of the implicit bias we have in our judgment on ourselves. From political and religious associations that cloud judgment to the fact that we always strive to see ourselves differently. Also, there are all sorts of ethical difficulties in actually testing and manipulating theories on us. Thus we normally study animals to get around this. However your question specifically talks about people so I will try and answer this based on biological theory alone.
Based on the foundations above, why would someone behave altruistically to someone only 'similar' to you? The biggest difficulty is knowing that we understand all the costs and benefits involved, most of the time we only know some of them and its impossible that you can know all of them because you can't know what you don't know. Humans have effectively 'bootstrapped' behaviours which are 'for the good of society' building on from previously developed behaviours. However we are still fundamentally asking a question about Hamilton's Rule. Being seen as a part of society induces altruistic behaviour towards you (because you are seen as worth something), this is good for you and the costs associated with being altruistic are usually low. Thus you would never rationally die for 1000 unrelated individuals unless you had at least had all the children you were going to have and raised them to be independent. But you would vote, by voting you suffer a tiny cost, your time, for a huge benefit. Benefits might include:
- Being seen as caring for others (altruism given to you)
- Possible benefits to yourself (less tax, more support, better roads, clean air.. etc)
- Possible benefits to others related to you
- General good moral of your community, leading to a better life.
There could be thousands of other benefits that I can't, off the top of my head, think of. The cost is negligible and the benefit is intangible but probably higher than the cost. Relatedness isn't important (so long as it is greater than 0), if the cost is sufficiently low or the benefit is sufficiently high. I hope this has helped clarify your thinking and answer the question.
For further information:
Provides the foundations
Hamilton W.D. (1963) Evolution of altruistic behaviour. The American Naturalist 97 354
Hamilton W.D. (1964) The Genetical Evolution of Social Behaviour I . Journal of Theoretical Biology 7 1
Hamilton W.D. (1964) The Genetical Evolution of Social Behaviour II. Journal of Theoretical Biology 7 17
The current controversy mentioned in another answer is from this paper, it is widely dislike but does have some support. It is slightly off topic from from the question here, but eusociality is fundamental to our understanding of evolutionary behaviour:
Nowak M.A., Tarnita C.E. & Wilson E.O. (2010) The Evolution of Eusociality. Nature 466 1057