Even until say a generation and half back. During my Dad's times it was quite usual for couples to >10 kids. It was considered a sign of pride!
Apart from that there are other social issues. Social security is a huge problem in India, Pension is a cruel joke. Other form of income during old age include rent from real estate or meagerly savings. Amidst all this kids are considered as a somebody who can take care of their parents.
For the west this might sound strange, but parents are a integral part of the family. In fact family means Parents, siblings and their kids included.
In all this Boys are considered cash cows. Because they are perceived as somebody who can earn and feed them in old age. Girls are considered money drains, as they marry and go away to their husbands home, to never return or contribute much. There is also a huge problem of dowry(Mandatory gifts given to girls during marriage) which makes girls look like burdens. The Indian middle class is also shy to send Girls to work.
All this contributes to 'reproduce until you get a boy' problem. The rest is left to your imagination. Especially when more population leads to more of it, merely by its very dynamics.
So you see the problem isn't that simple. Sometimes its genuine. Imagine you are old, need food, clothes, medical care. You need money for it, you see your neighbor get all the help from his son. While you get no help from your daughters.
The natural reaction is ... 'If at all, I had a son... I wouldn't be in this state today'.
These problems are not that simple to solve.