You could debate the "why"s of tax policy endlessly. There are lots of things in tax law that I think are bad ideas, and probably a few here and there that I think are good ideas. I am well aware that there are things that I think are good ideas that others think are bad ideas and vice versa.
To your specific point: I suppose you could say that having a place to live is a necessity. But most people do not live in the absolute minimum necessary to give them a place to sleep and protection from the weather. You could survive with a one-room apartment with a bed on one side and a toilet and some minimal cooking facilities on the other. Most people have considerably more than that. At some point that's luxury and not necessity. And if you want to push it, you COULD live in a cardboard box under a bridge, you don't NEED a house or apartment to survive.
Personally I think it's absurd that as a home-owner I get a deduction for my mortgage interest, while if someone were to rent an identical house with a monthly rental equal to exactly the same amount that I am paying on my mortgage, he would receive no deduction. The stated goal of that one was to encourage home ownership. But people who own homes are generally richer than those who rent, so the net result is that the poor are paying higher taxes to help subsidize the homes of the rich. And then the rich congratulate themselves on how they are giving these tax breaks to help make housing more affordable for poor people.
To reiterate @keshlam, tax laws only makes sense when understood politically. Yes, some people have fine ideas about what is fair and just. Others simply want tax breaks that benefit their business or people with tough financial situations that just happen by chance to resemble their own. Many of the people with noble ideas have little concept of what the implications of the policies they push are. Many of the ideas that some people view as worthy and noble, others view as frivolous, counter-productive, or even evil. Then you mash all these competing groups and interest together and see what comes out.