Why was the Church of the Holy Sepulcher built?

It was built to honor and protect the most sacred sites in the Holy Land and all Christianity - the site of Our Lord's crucifixion and his tomb.

In addition:
It ought to be added, however, that the church was built to honour and protect what tradition holds is the site of the Lord's tomb. In actual fact there are more than one contender for the tomb of Christ, as no one really knows the exact location. The present sepulchre, though likely to be the actual tomb, is not proven to be the actual tomb. This does not really matter, however, as Christians remember and honour what happened at the tomb and not the tomb itself.