If you were referring to "random creeps" instead of "random items", that requires a bit complicated steps. You can only execute this on the Mercenary Camp, a neutral building that allows you to hire creeps.
Basically, there's a rule regarding this system:
1.In Mercenary Camp, all four regular creeps were removed and replaced with the "hire random creep" item (there are 10 options, since creeps are sorted between level 1 and 10).
2.When an item is bought, you'll remove the item and spawn a random creep depending on what item was bought.
3.All creeps can be used on a certain map tilesets (this step is a bit long, but it's very simple: you need to alter the "Editor - Tilesets" field for every creeps in "Object Editor" by ticking the "All" options).
4.Of course, you need a trigger to execute this. The event must be "A unit sells a unit" and the action must be "Replace sold unit with your random creep".
This thread might be helpful:
i want to edit a melee map (echo isles for example) so that in mercanary camps you can only purchase random units. i want to have 10 buttons in a merc camp. - "recruit a random level 1 unit" - so for 100 gold you get a random level 1 unit from a collection of all level 1 unit type creeps (e.g...
www.hiveworkshop.com