High Statistics Measurement of the Positron Fraction in Primary Cosmic Rays of 0.5-500GeV with the Alpha Magnetic Spectrometer on the International Space Station