As adjectives applied to a task or an action, they are exactly the same:
"This is a hard test" = "This is a difficult test" = "Huu ni mtihani mgumu"
"It was hard to climb that hill" = "It was difficult to climb that hill" = "Ilikuwa vigumu kupanda kilima kile"
I would choose "difficult" for each of these if writing a paper or giving a presentation, but "hard" is fine in conversation.
But "hard" is also an adjective that can be applied to a material:
"This is hard wood" = "Huu ni mti mgumu"
You should not say "This is difficult wood". You could say this, but it means "This wood is difficult to work with".
"Hard" is also an adverb:
"I ran hard today" = "Nilikimbia kwa nguvu leo"
You cannot say "I ran difficult today".
Also, you can say "harder", for example "This wood is harder than that wood". You cannot say "difficulter".