Mammals evolved from a reptile, a cynodont therapid reptile. Reptiles lay eggs. The fact that the platypus has fur and milk and is warm blooded showed that these mammalian features evolved before live birth. Live birth has in fact evolved independently many times in reptiles,. For example, vipers, garter snakes, and some lizards have all evolved live birth.
Most egg-laying mammals have gone extinct, having been replaced by mammals that evolved live birth. The platypus is found in Australia, and Australia was once part of the super continent Pangea, which included Europe, Asia, North and South America, Africa and even New Zealand. Later Pangea broke up into separate continents, Australia became isolated quite early, before placental or marsupial mammals evolved, New Zealand in fact separated from the other continents before mammals even evolved. About 65 million years ago, a giant meteor the size of Mt. Everest struck the earth at high speed. The impact was the equivalent of 1 billion atomic bombs exploding at the same time, and it created oven-like temperatures on the ground. All dinosaurs, all enantiornithine birds, all marsupials in North America and Europe were wiped out. The only animals that survived were those who spent a lot of time underground (e.g. toads, snakes, lizards, salamanders, shrew-like mammals, marsupial shrews) or they were in or near the water (e.g. fish, turtles, frogs, newts, crocodilians, shorebirds that later became the ancestors of all living birds, and of course the platypus). The reason is that heat rises, so animals that were underground were not fried. Water also takes a lot of energy to heat up even just 1 degree, and so animals that were in the water were able to avoid being fried. Later, the marsupials recovered in South America, evolving from the surviving marsupial shrews, and shrew-like mammals in Eurasia, North America Africa also evolved into the living mammals we see today. Later, some marsupials migrated to Australia from South America across the Antarctica land bridge when it was not yet frozen.