I think it's best to research whether it's good in the openings and specific opening lines you play. General rules wont be useful.
For example in the Ruy Lopez, if you're aiming for d4 in one move early rather than the d3 systems then you may want to play h3 so your knight isn't pinned and can control d4. Other times the pin isn't a threat and the tempo may be best used elsewhere. You may even welcome the pin if the bishop wont be well placed on the kingside.
When I started to learn chess I always moved the a- or h-pawn next to the castled king so that there is an escapesquare for a backrankattack. Later I learned that this is bad because a) you cant move back so the pawns are less strong and b) it's a waste of tempo
So overtime I stopped doing that and now hardly ever push one of those pawns, only if its really nescessary. In mastergames it does happen though. Is there some kind of basic rule for that?
Why push the a- or h-pawn 1 or 2 moves? And when to do it and when not to?
I guess a reason could be: prevent a bishoppin (but quite often I dont really mind the pin as it can be solved) or it could be to attack a keysquare.. any other reasons?