Long long time ago, there were networks that had an MTU of only 500-600 bytes.
See this list for MTU-sizes of old layer-2 networks.
https://docs.appneta.com/book/export/html/532
I think Arcnet was quite popular before Ethernet took over as the one and only LAN-technology. And Arcnet had an small MTU.
I think in those days it was also common to configure smaller MTUs for slow-speed dialup-link, like 14.4Kbps modems, etc.
Nowadays everything assumes the minimum MTU is 1500 bytes.
But in the old days, it was different.
And DNS is a very old protocols (from the eigthies).
Fragmenting UDP packets is a problem. Or to be more precise, re-assembling them is a problem. It is expensive (you need to reserve memory to buffer the fragments, and you don't know how long you should keep those fragments around, if it seems one fragment was dropped somewhere). So the DNS guys wanted to prevent fragmenting, no matter what. So they defined the maximum size of a DNS packet in UDP to be so big it would always fit in an Arcnet packet, or some kinda value around 500 bytes.
If DNS was designed today, that number 500 would have been changed into 1500.
But the thinking was: if it is just one small query, with a small answer, and the whole reply will guaranteed fit in a single UDP-packet, then use UDP. But if there is more data to transmit than fits into 500 bytes, there is a chance we might need to fragment. And in that case, just use TCP. Simple.