The answer is that as embryos men and women have similar tissues and body parts. If anything the embryo follows a 'female template'. That is why nipples are present in both sexes. It is the effect of the genes, the Y chromosome and the hormone testosterone that brings about the changes and masculinises the embryo. Testosterone promotes the growth of the penis and testicles. Because nipples are there before this process begins the nipples stay!
Nipples and breast tissue have no function as such except for perhaps protecting the heart and lungs from injury.