Think of it as a way to express:
* Mild frustration: "Drat! I forgot my keys!"
* Disappointment: "Drat, we missed the bus!"
* A lighthearted curse: "Drat it all! I lost my lucky sock!"
It's often used in a playful or humorous way, especially in children's literature or when someone wants to express their feelings without resorting to stronger language.