We use first-principles methods to investigate the adsorption of Cu, Pb, Ag, and Mg onto a H-terminated Si surface. We show that Cu and Pb can adsorb strongly while Ag and Mg are fairly inert. In addition, two types of adsorption states are seen to exist for Pb. We also study the clustering energetics of Cu and Pb on the surface and find that while Cu clusters eagerly, Pb may prefer to form only small clusters of a few atoms. This kind of behavior of impurities is incorporated in kinetic Monte Carlo simulations of wet etching of Si. The simulation results agree with experiments supporting the idea that micromasking by Cu clusters and Pb atoms is the mechanism through which these impurities affect the etching process.