Dogs learn to play when they are puppies in the pack, and often playtime in social groups gives them useful life skills, like play fighting, hunting, or chasing.
Playing is necessary for a dog to have good mental, physical, and emotional health, even if it is done alone.