It's supposed to be to attract the females, the larger, brighter tail with finer feathers and more eyes indicate a stronger healthier, more successful and mature male - one that should be preferred, however, I spent a number of years raising Peafowl and never once saw a peahen pay much attention to the displays, though I got a lot of chicks anyway...:-)
They have these tails because it's what the females like. The male advertises his tail to the female to show her how strong and fit he to be able to survive in the wild with such a liability so the longer the tail, the better chance of a peacock mating in the wild.