The biggest issue is the key generation. The hardcore security of iOS is that only signed apps are allowed to run on your devices, unless you've jailbroken it and installed a package to bypass this, typically for non-licensed deploying or app pirating.
You need to generate a key based on Apple's certificate authority, or CA. Then you upload it to the portal and Apple approves it, provided you're a paid developer. Whenever you deploy an app, be it to the store or to your device for testing, you sign the app with your digital signature, which is backed by Apple. This tells your device, or your testers' or customer's devices, that the app is from a developer who is who he says he is. Since the main way to get an app on your device is through the store, you have the confidence that it is not tampered with (since the developer's signature is invalid with the flip of a single bit in the app) and that it's passed through Apple's checks by being hosted on the store. This is a two-fold assurance of the security.
Provisioning profiles are a whole other beast. Previously, Apple would let you "sideload" an app to any number of devices you wanted. This meant that you could bypass the App Store and sell apps yourself as a download, no different than desktop apps. Apple didn't approve of this and has since limited it to 100 devices per year being listed on a single developers account. You add your devices to the portal by it's UDID, it's unique fingerprint, and you would need to get this from any devices you wish to beta test your app or adhoc deploy to. Since it costs roughly $0.99 / year / device, it's prohibitively expensive to sell apps this way, but it allows you to have plenty of beta testing slots. Of course, a provisioning profile is the list of which devices can run which apps signed by who developer.
In recent Xcode's, once you've established your key (which would be difficult to automate from inside Xcode), you can plug in any iDevice, open the organizer and click "Use for Development". Xcode will prompt for your credentials and then automatically add the device to the portal and create a provisioning profile for you. Once you've done the initial setup, it's basically one-click to add an extra device. I don't think Apple is as worried about the initial setup being automated, since it's only a one-time process.
(Sorry, I'm trying to work on my long-windedness.)