There isn't a general answer because there are a myriad of reasons why. You should take him/her to a vet without delay as this could be very serious and your dog needs treatment whatever the reason. Please do the right thing and take him. Tk you
You need to get your dog checked out by the vet as this could either be arthritis, tendon/ligament damage, or a dislocated bone in the leg.
It could be it doesnt get enough exersise or its weak or its old tons of possible reasons