Depends on the riddle, but I typically don't like them.
I've been involved in too many games where the riddle was obviously pulled from a Google Search, "best riddle for D&D". I think I've heard the same riddle five times now.
I think the riddle has to fit into the world. I'm not interested if it's just a brainteaser - I'd rather play Wordle or the crossword puzzle. When I put a riddle into my game, it's typically designed to put the lore of the world (the stuff I'm interested in) into the hands of the players. So the party might stumble upon a Hags' lair, and the "riddle" is to put what they know about the Hag into tricking the magic-mouth door into letting them through.