Hydrofluoric acid is used to etch or write on glass because it reacts chemically with silicon dioxide, the main component of glass. This property makes it useful for creating frosted glass surfaces, marking glassware, and in industrial applications for glass etching and cleaning.