How do i unlock my iphone 5

i have a iphone 5 I forgot the password for it and im trying to restore it to factory setting but I keep getting a error message saying it cannot install software on iphone. what should I do? I heard that I will not be able to put ios7 but I don't mind as long as I can put the original software and be able to use the phone. can someone help me ?