Use brew installer instead:
gem uninstall cocoapods
brew install cocoapods
Or if you use Apple M1 you can try install by this command line
arch -x86_64 brew install cocoapods
arch -x86_64 brew reinstall cocoapods
Reference: Github Issue