As far as I know there is no general rule on how to do this.
I can only tell you how I do it:
numbers → no quotes
time → quotes
text without special characters or whitespace → no quotes
text with special character or whitespace → quotes
value “on” or “off” → quotes, because otherwise HA doesn’t recognize it correctly
In my opinion the second example you showed looks cleaner and nicer than the one you propose, but that’s just my view. And to be honest, I don’t really care whether there are quotes around a string or not as long as the thing works as intented.
I think it’s not necessary, it will not provide any additional value for you or others reading your code and therefore I see it as a thing to do, when you have nothing else to do. I care more about readability of my code.