The installation of any Ruby version may fail with a problem linking openssl. The workaround is:
$ brew link --overwrite openssl
$ rbenv install 2.7.1
$ brew unlink openssl