The ability for some animals to have live births versus eggs can normally be explained by what classification the animal belongs to.
Mammals have live births, birds have eggs, Echidnas (a relative of mammals, think platypus) have eggs (like birds) but also have some characteristics only seen in mammals (fur and milk for their young).
There are some classification of animals that can have either live birth or eggs, such as sharks, fish and some reptiles.
The difference between the whether there are live births versus eggs is usually determined by the environment.