I can’t find anything on the origin of Jotunheim. If it was linked, like Muspellheim, to Nilfheim in any way… and I’m not sure how did Ymir arrived in it… I guess it could be unknown like many other details of the Norse mythology, but at least I can ask a question…
Based on the creation myth as described on wikipedia I would infer that Jotunheim was created when the gods Odin, Vili, and Vé created the Earth from Ymir's body, and used Ymir's eyelashes* to separate Midgard from the outlying lands (which would be Jotunheim).
Ymir had come into being in Ginunngagap from the interaction between the ice of Niflheim and the fire from Muspelheim.
* Or eyebrows according to another source