Why only female mammals have well developed mammary glands?
It comes down to investment in offspring. Males invest little in offspring only a little sperm whilst females have to develop the more expensive egg and the energy used through its development. In the mammalian line, this investment has increased in amount, initially through viviparity and then through the secretion of feeding fluids.

In species, such as humans, where there is a lasting pair bond and both male and female invest in rearing the young then I suppose there could be a situation where it makes equal sense for both males and females to nurse - although the cost of mammaries on other functions may favour specialisation anyway - but remember that, in many mammals, it is the mother alone that rears the offspring.

You may also find the answer to this question useful: Do any birds beside the family Columbidae (or any reptile or mammal) feed their young “Crop Milk”. What I hadn't realised is that there actually two species of bats where the male lactates.