The tensor renormalization group for pure and disordered two-dimensional lattice systems