>>936608791
Laying eggs means you’re sort of locked in the same area until they hatch, and need to guard them. If a weather event that makes it hard to find food, or a pack of predators roll in, you either have to abandon your clutch, and get out, losing a breeding season and all the resources you put into the eggs, or face the risk of starvation / predation.
A mammal on the other hand can move on with no risk.
A lot of animals also evolved to eat eggs, so there’s a lot of risk compared to carrying young internally. It’s very rare for a species to be able to watch their eggs at all times.