Did you remove that covering (split loom) off of those two sets of wires that I can see in the pics? Cut that tie strap off, and the split loom can be removed. You might have to remove some electrical tape if you are at the end of the loom otherwise just stick a tool into the split and remove the wires that are loose inside. Pull them out of the split loom and inspect for one that has a loose end. I’m thinking there might be a wire inside of that loom that your loose wire used to connect to.
As far as the ignition being on and then connecting the battery and then letting the battery die, you might have fried the powertrain control module ( PCM) which on that year 6.0 is both the engine control module and transmission control module. If you did that, you’ll have to get a replacement programmed to your VIN and then do a VATS relearn. If you have a Tech2 you can do it yourself, if not a shop will have to do it. Used PCM’s can be bought on eBay. You’ll need to get the p/n off yours. It’s under the battery in the engine compartment, it has 2 big connectors with a hundred wires going to it.