Today it's purely a cosmetic thing(for looks), but years ago Great Danes were bred to catch wild boars. Danes ears are long and floopy, and the boars used to be able to grab onto the ear. They started cropping the ears so the boar couldn't get to them. I don't know why other breeds get cropped, but there's people here that can answer for their breed. Great Danes tails are not to be docked unless they have severe "Happy Tail" syndrome. Which means the dog has whacked it's tail off of something, split it, and if they can't get it to heal, they amputate part of the tail. Fin
There is for looks and shows, but it does still serve a purpose. Working dogs have their ears cropped to prevent them from being ripped and torn. It keeps them out of the way because, well there not there. Its almost like having your hair cut for a human. If you are going to be hunting in the brush, with bushes and thorns your hair would get stuck and pulled out. Pigs/boars run deep in the woods sometimes and the dogs got to go in and catch them, having their ears cropped as a puppy saves them from being torn/ripped during the hunt as an adult where it is painful to have a rip, can get infected easier and a big deal to crop. I'd say most people get it done because they like the look or show dogs, but there is still a purpose when it comes to working dogs. About the tails I dont know?
I have my bird dogs' tails docked so they do not get ripped and torn when they are taken out for field work. The tail is one of the most commonly injured places on a working field dog. It can be painful and difficult to treat so docking becomes the most humane way of safety for them. ~Seij
When the practice began, the purpose was to pretect the dog from being torn up and hurt when they were practicing their job, be it hutning, etc. Now it's become about show, standard, and looks. Though it still can be useful, it's not usually done for the purpose of health and safety.
Someone kindly pointed out to me on this very forum not long ago that as far as the Cropping and docking goes, the only thing that has to be done to compete in the show ring is the tail docks. Ear crops are optional...although I have yet to see any uncropped breeds (that have it done anyway) compete at the national level.