For maximum tire pressure I’d stick to the limits set by the tire and rim. Too high and your rim or tire can be damaged.
For minimum tire pressure the main problem is pinch flats when you ride over sharp edges. I like to use the following trick: Find a nice sharp edge like a curb stone or stairs. Put your front tire on the edge and press down with all your weight. If you can push all the way to the rim your tire pressure is probably too low (or right at the limit). At very low pressures the tire can buckle sideways and roll off the rim in turns, so you might want to try a few sharp turns and watch for any buckling or unstable feeling.
Low pressure will improve comfort and grip on loose/uneven surfaces. High pressure will improve rolling resistance.
On smooth surfaces you can go as high as you want (up to maximum pressure). The only disadvantages are reduced comfort and reduced grip if you unexpectedly encounter gravel or other bad surfaces.
There are some theories and studies (though only bad ones as far as I’m aware) stating that very high pressures can be counter-productive at some point because you lose energy to all the small vibrations and up/down movement. So you might not want to overdo it. With good, supple tires rolling resistance increases surprisingly little when you lower pressure.
A lot of it depends on circumstances. Surface, tire, rider weight, weight distribution, bike geometry, bike suspension, speed, riding skills, importance of comfort …