Why does two nails of the same material not produce electricity when placed in saltwater?
First, you need to understand what is electricity. Electricity is simply the flow of electrons. Now, what I really suspect you are asking is why these electrons flow. 

Electrons flow in an electric current due to a potential difference which is the difference in potential energy of the electron at two different places. Like everything else, electrons like to lower their potential energy (imagine water falling in a waterfall) hence in an electric current, electrons move because they are moving from a place of high potential energy to a place of lower potential energy.

Now when you place two of the same nails in a salt solution, there is no potential difference between the two nails as the potential energy of the electron moving from the two nails remain the same (since they are made of the same material).

However when you place two different metals into salt water, such as aluminium and copper, there is now a potential difference between the two metals. Hence this will cause the electrons to move creating electricity (an electric current).

For more detail about the voltage change and what the chemical reactions that are actually occurring and you google electrochemical cells and electrochemical series. Hyperphysics and Chemguide are both very good resources which provide in-depth explanation on what is actually going on.