I am not sure what to suggest, a Pi4 with 2GB would have been my answer in pre Pi5 times... and still, the Pi4 runs an official image, but the pi5 ain't such a newcomer nowadays and the official image is still based on (IIRC) buster and since then, even before the Pi5 was released, the discussions where about when there will be a "bullseye" image and whether it will be 64bit/32bit or still in support of 32bit ... sigh...
So the official image is missing debian 11, the 64 vs. and or 32 bit problematic still unsolved and now with the pi5 we are over the edge to 64bit and on bookworm as the current debian/raspi OS base...
I would say, it depends... if you want to play straight ahead and use the existing image, go for a pi4 with whatever mem you may need to reuse it after upgrading retropie to a newer device (for retropie on a RP4 2GB is IMHO more then enough, if you want to use it as a terraria or minecraft server afterwards, at least 4GB better 8 would be the way to go).
But if you are totally new to raspis and retropie... well, bad timing, if you simply can afford it, go for the above mentioned route of the pi4 and learn some *nix basics ... but be assured that all you learn for the nowadays official buster based image is void for the next official one, because too much on the underlying OS was changed (just to add a match of buzzword: config.txt vs. cmdline.txt) - if you are willing to experiment and learn on raspberry pi/*nix in general in the meantime, go for a pi5 with the memory you can afford!