Warning: long answer.
General idea
Now, I know this would sound a bit odd (well, a bit might be too soft expression), but one of the things, that came to my mind after reading the question is from Dumbledore's speech at the end of Goblet of Fire:
“Remember Cedric. Remember, if the time should come when you have to
make a choice between what is right and what is easy, remember what
happened to a boy who was good, and kind, and brave, because he
strayed across the path of Lord Voldemort. Remember Cedric Diggory.”
I am very well aware of the fact, that Dumbledore is talking about kinda different situation. About the time when you must reveal, whether can fight for something, no matter the circumstances, and you stand to your best beliefs or if you cowardly stir yourself from your responsibilities and you sell yourself to the other side ( if you let me simplify it).
Now, I believe, that Dumbledore was talking about a very deep concept of principle upon you can build your life. A concept of making everyday or lifetime decisions, of taking the burden of responsibilities. You may then find, that what can matter is:
- what is your motivation, what drives you in your life
- how do you those things, if you can choose
- whether you care about those around you
Harry's own motivation
I think Harry is this kind of person.
Together, as said in the answer above, it was improper because of Harry's feelings towards Dobby, who while sometimes too much, cared for Harry's good. whether it was :
- fighting the Elf law of keeping family secrets (Chamber of secrets)
- helping with the second task of the Triwizard Tournament (Goblet of Fire)
- tailing Draco Malfoy, which meant not sleeping for many days (Half Blood Prince)
- saving Harry and others from the Malfoy's Mansion
- and others...
Harry realized this, I think. And well, there was not very much he could do for Dobby now, there was after all, nothing at all, that he could do for him.
He might remember the Christmas, when he did not think of Dobby, although Dobby thought of him:
“Can Dobby give Harry Potter his present?” he squeaked tentatively. “
’Course you can,” said Harry. “Er . . . I’ve got something for you
too.” It was a lie; he hadn’t bought anything for Dobby at all, but he
quickly opened his trunk and pulled out a particularly knobbly
rolled-up pair of socks.
He might feel pity, that he would not be able to repay to Dobby (not only this time, but also the other mentioned above).
The last thing, merely symbolic, was to honor Dobby by digging the grave with his own hands. To actually sweat and at least for a moment work as Dobby did his whole life.
A bit more about "no magic!"
Doing something very uneasy way is often considered character building process. Since it takes much more time, you can think about it. Parents/teachers use this punishment to teach you, that some things you should not take for granted, that is:
to expect something to be available all the time and forget that you
are lucky to have it
the free dictionary
Aside from the part about Molly Weasley I do remember four more occasions:
In the real world imagine having to write many page essay by hand, no use of computer. Or searching for the information in the book, no internet.
Those things done by hand are somehow more real. It is not easy, it takes a much more time, if you do a mistake (/accident - spilled ink), you might need to e.g. rewrite the whole page just because of that one thing. During the process you are almost forced to concentrate only on your work, it gives you plenty of time to think about the circumstances, that led to it.
Now, it does not need to be only punishment. I think Harry did it as a sacrifice of his time(well, not just time); remember, how he was in hurry to get the information from Griphook and Ollivander after the burial. But he stopped everything about the Horcruxes and Hallows to honor his friend, a friend who was in the eyes of the majority of wizards seen as a filthy servant (for being a House Elf).
He dug with a kind of fury, relishing the manual work, glorying in the
non-magic of it, for every drop of his sweat and every blister felt
like a gift to the elf who had saved their lives.