A hat earns its place for one of two reasons, and it's worth knowing which one you're buying for before you pick it up. Either it's doing a job, keeping rain off your head, keeping sun out of your eyes, keeping hair under control on a bad day, or it's doing the work a good coat does, pulling an outfit together without you having to think too hard. Most of us own a mix of both and reach for different ones depending on whether we're walking the dog or trying to look like we have our life together.
Colour wise, I've found the ones that get worn most are in navy, charcoal, camel or a soft olive, because they go over everything without an argument. A bright hat can be lovely but it tends to date the outfit you're wearing it with, whereas a neutral one sits quietly on top of a plain coat, a denim jacket, even a smart blazer, and doesn't pick a fight with anything underneath. Black is the safest of the lot but can look a bit severe on its own against pale coats, so I'd pair it with something that has a bit of texture, a chunky knit scarf or a tweed coat, to soften it. For pairing generally, keep the rest of the outfit simple if the hat has any kind of shape or statement to it, a wide brim or a slouchy beanie wants plain layers underneath, not another busy pattern competing for attention. Season wise, wool and knitted styles are obviously for fighting the cold, cotton caps and visors are for the bit of the year when the sun's actually out and you need your eyes shaded rather than your ears warmed, and neither does well standing in for the other, a knitted beanie in August is a sweaty mistake I've made more than once.
The difference between a hat that lasts and one that ends up at the back of a drawer by November comes down to a few boring but important things. Check the stitching round the brim or the seam of a beanie, loose threads there mean it'll be out of shape within a month. Hardware matters too, a cheap metal buckle on a cap strap will go rusty the first wet week it meets, so look for something coated or plastic that isn't going to mark your coat. Fabric should have a bit of weight to it, thin felt or flimsy acrylic knit loses its shape and goes bobbly fast, while a proper wool blend or a decent cotton twill keeps its line wear after wear. If you're starting with one, go for navy, it does more work than black without trying half as hard.