Here on the internet people just explain the difference between the two and how you should also apply the handbrake when it gets steep, but why is there even a parking gear in the first place when you can just use the handbrake?
Putting the transmission into "Park" engages the "parking pawl" - essentially a metal pin that locks the output shaft of transmission (and thus the driven wheels) in place.
As to why it exists - it is intended as additional roll-away protection that complements (rather than replaces) the handbrake (which, as the name implies applies actual brakes - usually to the rear wheels). The idea being that if either the handbrake or the pawl fails there's still something to prevent the car rolling away.
Handbrakes, like regular ones wear and thus become less effective with repeated use - and this isn't always immediately apparent to the driver so an extra safety net isn't a bad idea.
Modern car systems also talk to each other - in more recent cars its impossible to start the motor while the car is in gear. So the gearstick has to be in Park or perhaps Neutral, perhaps with the brake pedal pressed or some other combination.
This is another safety interlock to stop a driver rolling on engine-start because the gearbox was left in a gear.
Of course there are very rare situations you might need to move/bump the car on the starter alone, which is now impossible. The classic Driver's Ed example was "stalled on a railway level crossing with a train coming and motor won't start"
Also, by putting the transmission into park you're also telling the car its not going to move for a bit, so the computer may choose different courses of action for the engine compared to if you were simply stopped at a red light.
The two options enable two completely different systems -- in principle, at least,
Putting your car in "Park"
This locks your central transmission into a fixed state, by mechanically freezing the clutch. (Exact approach on how that works depends on the specific model of car.) That means that your wheels are still free to roll -- even on a steep hill -- and you're relying on that transmission-locking mechanism to resist moving.
If you're on anything but a steep hill, then putting your car in "Park" is just fine. Period. Engaging the hand-brake is completely redundant. (And if your car is less than 20 years old, there's a good chance it wouldn't make any difference at all.)
Using the Parking/Emergency Brake
This is basically just a second brake pedal. Pulling on it engages the brake pads on each wheel, as if you were stomping on the brake. Locking it in place is pretty much the same as if you stomped down like that, and then just sat there like that for a couple of hours. (Again, the exact implementation completely depends on the specific model of car.)
If you're actually on a steep hill, then engaging the hand-brake is -- again, in principle -- a more reliable option, since you're now relying on your brake pads to stop your wheels from spinning at all. Those pads are designed bring your car to a screaming stop from 50+mph to zero in a matter of seconds. Asking them to resist the force of slowly rolling down any slope, no matter how steep, is trivial.
Given all that, there are still some important points to keep in mind...
The underlying concepts of how a car "works" for these are so outdated that they're almost completely irrelevant. All of this guidance stems from a time that "cars" were purely mechanical systems, and questions of how to balance one system against another (like this one) really made a difference in the longevity and performance of a car. Modern cars are such complex, automated entities that this is all very likely moot for any car manufactured in the past 20 years -- I'd be pretty shocked if "putting the car in Park" and "pulling on the handbrake" aren't really just the equivalent of pushing the same button, two different ways, in most modern cars.
None of this is really valuable, compared to the most important single piece of advice for parking on a steep hill...
Curb Your Wheels.
Curb Your Wheels.