There are many theories about how the eggs got aboard the derelict. The nature of the derelict and its crew are a mystery, left intentionally unanswered by the original crew that produced Alien. Viewers have proposed various theories, such as:
Theory One: The Queen burst from the derelict's pilot. He may have been the only crew member on the ship, so once he died, the ship crashed, leaving the Queen time to lay thousands of eggs, then hibernate, until visitors came.
Theory Two: The Space Jockey was some sort of scientist. He investigated a planet and found the eggs, loaded them onto his ship to examine, and was then impregnated by one. When he came to, not knowing what had happened to him, he took off into space. The alien then birthed, and he crashed with all the eggs intact (no queen present).
Theory Three: Ignoring the continuity with the franchise and speculating on the original idea behind the aliens: the ship had a large crew, who were turned into eggs (as per a theory stemming from the director's cut). This would also mean that Lambert's comment "I wonder what happened to the rest of the crew" was a subtle hint this was the original intention. If this is what happened then, there was never supposed to be a queen, and the Alien itself was the final stage. This theory is extremely unlikely, as the Space Jockey and its species are far too big to turn into little eggs. Not to mention; if everyone is turned into eggs, then who is left to impregnate?
Theory Four: The Queen was on the ship, laid the eggs, but died off or was killed in the crash. It said that the Space Jockey had been dead for so long it had become fossilized, suggesting the ship had been there for thousands and thousands of years. (It's suggested the Aliens don't age or die naturally from both the fact that the eggs survived in the ship for all that time and the fact that Ash says, "I have confirmed that he's got an outer layer of protein polysaccharides. Has a funny habit of shedding his cells and replacing them with polarized silicon, which gives him a prolonged resistance to adverse environmental conditions."). So a new queen wasn't birthed until Aliens, possibly from Newt's father.
Theory Five: Director Ridley Scott explained in interview that he envisioned the derelict as a sort of carrier for biological weapons; the eggs were intentional cargo, but naturally, something went wrong. This is certainly consistent with the Company's obsession with obtaining a specimen for their bio-weapons research. The 2012 film Prometheus which is a prequel to the Alien series, supports this: in it, Company researchers discover an old colony of the Space Jockey race (called Engineers now), where they keep a black liquid containing very small organisms with highly mutagenic properties. Infection with the liquid produces various results: some humans start to mutate into gruelling monstrosities; one of the female workers births a squid-like organism after having sex with her infected partner; the squid subsequently "impregnates" one of the Engineers like a facehugger, which in turn causes an Alien-like creature to burst out from the Engineer. This may suggest that the Engineers experimented with the black liquid, and finally produced the Alien species, which they used as bio-weapons.