Though these words look and sound very similar, using the incorrect one will change the meaning of your sentence completely.
Hard is an adjective that means “solid, industrious, or difficult” or an adverb that means “with a lot of effort”
For example:- Heating the clay makes it hard (solid) . She is a hard (industrious) worker. It was a hard (difficult) test. He is trying hard (with a lot of effort) to learn the guitar.
Hardly is an adverb and means “only just/very little or certainly not.”
For example:- The teacher spoke so quietly I could hardly (only just) hear her. You can hardly (certainly not) expect me to do the test for you!