The physical understanding of glass transition remains a major challenge of physics and materials science. Among various glass-forming liquids, a colloidal liquid interacting with hard-core repulsion is now regarded as one of the most ideal model systems. Here we study the structure and dynamics of three-dimensional polydisperse colloidal liquids by Brownian dynamics simulations. We reveal that medium-range crystalline bond orientational order of the hexagonal close packed structure grows in size and lifetime with increasing packing fraction. We show that dynamic heterogeneity may be a direct consequence of this transient structural ordering, which suggests its origin is thermodynamic rather than kinetic. We also reveal that nucleation of crystals preferentially occurs in regions of high medium-range order, reflecting the low crystal-liquid interfacial energy there. These findings may shed new light not only on the fundamental nature of the glass transition, but also the mechanism of crystal nucleation.