Transformers Can Overcome the Curse of Dimensionality: A Theoretical Study from an Approximation Perspective