I tend to recommend renting
until you know you are going to sail enough to be worth buying
Some rental places want some indication you know what you are doing before you rent the boat.
For the small beginner boats its usually just a few questions on basic operation and how to tack (so they don't have to tow you back in)
For larger boats they may require some level of certification
You can rent a Sunfish for a day... learn quite a bit. Dump it a bunch of times and have fun.
Rent something the size of a Laser and learn some more... I'd dump it once just to get the feel, but they aren't as easy to get back upright solo. (longer, heavier mast)
Rent the size you think you want... From dumping the smaller boats you'll have a bit of a feel for when to unload the sails
to prevent going over.
Remember that if you buy a boat with fixed keel
or above about 20 ft even with a swing keel
... trailering and stepping the mast
for a couple hourts of sailing can get to be annoying and you'll probably want to rent a slip.
This is where people get in trouble... they buy a boat that has to be in a rented slip and don't use it.
It becomes a hole in the water
demanding to be filled with money
and it leaks
Too many boats sit tied up, never used, slowly rotting. By the time you quit paying the slip fee the boat is in bad shape and the marina getting a lien so they can auction/sell it ends up with them having it hauled off for demolition.
So... RENT until you prove you will use it enough to really be worth buying