How to maximize the benefit of an exchange opportunity during PhD
This is standard practice in Denmark (where I'm currently located). All PhD students are essentially required to spend 3-6 months at a foreign institution. Similarly we host a large number of PhD students in our department for stays of about this length. So, this is a question that's pretty relevant.

To take advantage of this opportunity you have to think about what you personally hope to get out of it. I'd say there are several possibilities:


Discussing your research with people outside of your lab and narrow subfield. This can be a great opportunity to get novel feedback and insights. But, you need to make sure you actually have the chance to do this. Does the lab you're going to have regular meetings? Do you have a chance to present your work? Will you be able to go to local workshops/meetings/conferences at the host institution? We sometimes have students who end up not getting a lot of face time with members of their host institutions, which is unfortunate and you want to avoid that.
Learning whether there are other areas of your discipline that are interesting besides what you're currently working. Presumably after you're done with your PhD you'll have to move somewhere else. This may require you "branch out" slightly from your current research work into related areas. This might be a good opportunity to learn about somewhat related work and get some knowledge that might help you start a new project, or land a postdoc or assistant professorship in the future.
Getting a feel for another department. All departments and labs are different. They have different culture, different norms, different levels of social interaction, etc. This is a great time to see how another lab/department/university works and via that experience get some insight into aspects of that environment (and your home institution) that you do and do not like. This can be valuable for deciding what kind of environments you'd like to be part of in the future.
Networking. Going to another institution is a great way to broaden your network. But, you need to make sure you'll actually get a chance to meet people. You don't want to end up going somewhere and just sitting in your office the whole time alone. Make sure there's a network of PhD students you can meet while you there and that you make a concerted effort to meet with faculty. And, outside of work, try to make some friends.


So, to prepare, figure out what you want to get out of the experience and then make sure the institution can satisfy those things (and, as part of that, try to setup the desired opportunities in advanced by scheduling meetings, etc.).