Elephants are not small animals, and as pets, they are problematic to say the least; very expensive to feed, bath time is a chore and clean-up can be a massive operation.
In most of Asia, traditionally, elephants were put to work to earn their keep and their hundreds of pounds of daily food they eat. They worked, and in some areas, still work on logging plantations, in fields etc.
But a white elephant never works, why? Well, on the eve of giving birth to Buddha, his mother dreamed of a white elephant handing her a lotus flower and from that conception legend, white elephants have always been sacred in Buddhist parts of the world.
When colonialism, namely the British, came to Southeast Asia, they saw the “white elephants” and saw the cost and expense of keeping such a massive creature for literally decades and soon the phrase came to mean a bloated expensive useless project.
Wikipedia has a list of some pretty humorous and amazingly expensive white elephant projects here.