The spider that bit Miles was pulled into his dimension by the Alchemax particle collider at the start of Into the Spider-Verse. We don't really learn more about it until Across the Spider-Verse. The spider was brought here as part of the particle collider experiment and was labeled with the universe it came from: 42.