The present invention relates to a novel pyrrolopyridine compound represented by Chemical Formula I, a racemate or a stereoisomer thereof, or a pharmaceutically acceptable salt thereof; and to a method for preparing the same. A compound represented by Chemical Formula I shows high selectivity and antiviral activity against human immunodeficiency virus (HIV), with low toxicity; therefore, it is useful as a therapeutic agent for viral infection, in particular, HIV infection.