Well currently nails can be made of many materials. But typically a nail is made using iron, and this is due to the nature of its use. Most nails are made to withstand hundreds of pounds of force before breaking. By mass iron is considered the most common element on Earth, and most of our structures require the need for nails.
Nails need to be made cheap, and iron is a cheap metal available in most places. Though, the metal is soft and brittle without proper treatment. This treatment is reffered to as being "galvanized". This helps give the nail some strength and resistance to corrosion. Iron makes a great material to help secure wood, plastic, and even other metals.
Originally iron nails had been made by hand by the local blacksmith. You may find that these old nails are square instead of round due to the hammering process. But technology has allowed for the manufacturing of as many as 500 to 700 nails a minute with current machines. These are generally built like an assembly line, and are designed to create perfect identical nails everytime. Testing is done to make sure the nails meet the desired requirments.
The earliest nail on record comes from Egypt. It has been dated to 3400BC and is made of bronze. We also have many biblical references to nails, that have contributed to our knowledge of them in some areas within history. It was believed that in ancient Egypt, nails would be considered valuable for trade, and could serve as a form of tinder when other forms of curency are not viable.