Can someone please explain how they exactly work?
First, you need a high enough standing to talk to the agent.
Second, you need to have a skill trained that they research in.
Once you meet those requirements talk to them and research begins. You gain RP over time based on the agents level in the given skill, your level in the given skill, and agent quality. You can do missions for RP bonuses, but that is all you get from them. No rewards, faction, or LP.
Can you drop the agent you are using for a better one?
You can drop a research agent at any time, but you lose any RP gained.
And by doing R&D can you get standing towards that corp?
Reverse that. Do missions for that corp to gain standing with the R+D agent.