Is it possible to do a factory reset of iPhone 5 and keep iOS 6?
You cannot reset your phone, or it will need you to change to latest iOS 8. Apple doesn't sign old iOS versions which means it's impossible to restore an old iOS version.  
If you want to just wipe the texts and contacts, that's an easier task. 


If you have ever synced your iPhone with iTunes, you just need to sync it in the following fashion:  


if you usually sync the contacts and texts, you could uncheck the contacts and texts sync and erase those manually.
if you don't usually use iTunes, or need a faster approach to delete everything, I'd recommend using iTools PC/Mac app. (Just Google it).


Finally, you should use a blank space wipe tool (such as Battery Doctor) to assure that no erased data remains on the device.