Can you tell me why my pear tree leaves have these brown spots on them
Those are insects called "scale". This is one of many, many armored scale species. These are much smaller, and harder to spot than some of their larger cousins. Since they cap themselves over with a protective armor "scale" it will be difficult to treat. It takes persistence and a watchful eye.I would suggest removing all that you can by hand. Using water, physically wipe them off of the leaves and bark. This can cut down on what you are going to have to treat. After you have removed as many as possible, you can treat with an insecticide. This can be chemical or natural, depending on your choice. Treatment will need to be done several times.
https://www.gardeningknowhow.com/plant-problems/pests/insects/control-plant-scale.htm
I have a pear tree for almost 20 years, good harvest every Aug/Sep, however fruit grow ugly recent years and fruit almost inedible. I consulted a local garden center, they told me that it is kind of disease which cannot be cured. Only way is to cut down the tree. Of course if there is other way, I really want o save the tree. Thanks in advance.
It could be cork spot disease. Here is more on its management:
https://ohioline.osu.edu/factsheet/plpath-fru-01
https://www.gardeningknowhow.com/edible/fruits/apples/treating-apple-cork-spot.htm
my pear tree is 4 years old it flowers fruits then the fruits turn black and drop of every year there is another pear tree next to it which is not affected
It likely has a fungal infection that is overwintering every year. It could be pear scab, sooty blotch or a leaf spot disease. It may even be due to a pest such as the sawfly. These articles will help pinpoint the problem and offer a solution:
https://www.gardeningknowhow.com/edible/fruits/pear/pear-tree-diseases.htm
https://www.gardeningknowhow.com/edible/fruits/pear/fixing-pear-tree-problems.htm
https://www.gardeningknowhow.com/edible/fruits/pear/pear-sooty-blotch-treatment.htm
https://ag.umass.edu/fruit/fact-sheets/pear-ipm-pear-scab
https://www.gardeningknowhow.com/edible/fruits/pear/pear-black-rot-information.htm
https://digitalcommons.usu.edu/cgi/viewcontent.cgi?article=1971&context=extension_curall