Dogs were originally domesticated and bred because they were/are useful to mankind.
Actually, I have to differ with you, in part here. Originally, the only use dogs had was eating garbage. Originally, as they became domesticated, it is thought that for a very long time, humans had very little to do with them. They just hung out and ate human left overs. Quite some time later, they were discovered to have some uses other than eating garbage and about that time, different breeds
began to be developed.
Different breeds were developed to serve different purposes and the idea of ""lap dogs"" wasnt developed until much later
Again, I'm not sure what you mean by much later. But, Chihuahuas are quite an ancient breed, especially their predesessors. And the only thing they were bred to do before being bred as companions was to be bred as a food source and religious sacrificial source. I believe there are some other pretty early lap dogs. Some working dogs that we have today were developed more recently.
However, it really is a moot point when they were developed for companionship. The fact is, there are dogs who are perfectly happy and well adjusted being companions. I think all dogs need a "job." But that can be anything from learning some obedience, to good house manners, to playing fetch or learning how to walk nicely on a leash....anything where the owner is a good "parent" or leader and where the dog has something to do....something where the owner asks and the dog gives. And then the dog gets. LOL.
My Doberman needs more busy work to keep him happy than my Chihuahuas. Different breeds do vary in their need for stimulation. But that doesn't make one breed any less a real dog than another....don't get that connection.