If collisions between gas particles and container walls were not elastic, the gas would eventually lose energy and come to a stop. This is because in an inelastic collision, some of the kinetic energy of the particles is lost as heat or sound. Over time, this loss of energy would cause the gas particles to slow down and eventually stop moving altogether.
In a real gas, collisions between particles and container walls are not perfectly elastic, but they are very close to being so. This means that the gas does not lose a significant amount of energy in each collision, and it can continue to move freely for a long period of time.