Not so much why oats , as why wild oats . The saying is referring to a European grass species with the formal name Avena fatua , which has for centuries in English been called wild oats .
Some botanists think it's the wild original of cultivated oats.
Farmers have since ancient times hated it because it's a weed that's useless as a cereal crop, but its seeds have always been difficult to separate from those of useful cereals and so tended to survive and multiply from year to year. The only way to remove it was to tramp the fields and hand-weed it. Even today it's still a problem, despite modern seed cleaning and selective weedkillers. So sowing wild oats was the archetypal useless occupation, indeed worse than useless. It's not surprising that the phrase sowing wild oats was applied figuratively to young men who frittered away their time in stupid or idle pastimes.