You cannot successful ask and answer questions of this type in an absolute sense because the correct answer depends on four things:
- The terrain power of your start position
- The Civ you are playing
- The map size/landmass ratio
- the strategy/victory condition you are going for
If you are playing the Iroquois in the tundra instead of playing Japan on grassland the answer will be different.
Only civs that have pottery to start with (expansionists) can build the Granary from the get-go anyway; and only industrious civs have masonry to build the pyramids right away. America is the only civ where this question always applies in the beginning turn.
Look first to understanding how to improve the power of your start position regardless of what civ and map you play.
Read the article on
Improving Your Opening Play Sequences
and then look to try and optimize your initial cities to perform one key task: expansion, military, or productivity for wonders/improvements.
Current testing of gameplay mechanics suggests that building the granary early is useful in about 1/2 the starting situations.
Building the great pyramids is a bigger debate because on certain map sizes and landmass setting it is far better to capture the pyramids than waste time building them yourself. You have to become far more of a master at managing happiness and productivity if you have the Great Pyramids because your population will usually outgrow your skills and abilities to provide military police, luxuries, and other growth/happiness support infrastructure. I use the F11 key to monitor my enemies early and then when I get the ability to use the F7 key I plan ahead for the cities that are building the great pyramids. When I get the pop up anouncement that one of them has built the pyramids you can gues what happens within the next 3 or 4 turns.
I would rarely advocate dedicating my capital to accumulate shields for building a wonder until I have at least 6 or 8 towns in place. On the easy difficulty levels you may not get poached by other civs beating you to the wonder, but on Monarch and above the AI's get to build wonders cheaper than you do so poaching and cascade is a common occurance. When you lock your capital into building a wonder you do not have the ability to fall back into building a palace to recoup shields that may be lost.