Ruby < 2.5 fails to install on macOS Big Sur with rbenv because xCode 12 removes outdated packages and it's impossible to rollback to xCode 11.5 and Commandline Tools older version than actual. There are few steps to fix this.
brew install rbenv/tap/openssl@1.0
# view more details at https://stackoverflow.com/questions/59337838/openssl-1-0-2m-on-macos
Those libraries should be installed already on your system
RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl@1.0 --with-readline-dir=$(brew --prefix readline)" CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.2.2
If fails, try this and repeat step 3.
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
This should help.