In short, you can't play PS5 games directly from an external hard drive (although you can, for whatever reason, play PS4 games from one, and if it's an SSD they'll load faster than ever before), but you can use it to store games when you're not playing them and make room on the internal drive for other titles.
Thankfully the PS5 supports external hard drives as long as they have USB 3.1 connections, but it helps to read the small print. This means that you only have around 667GB of storage to play with, and it won't take many AAA games to eat up most of it.