On the basis of observation: Managers observe and analyse the day to day happenings in a workplace. With that they come to know what problems are being faced by the company as well as what measures are needed to be taken in order to overcome such obstacles. For example, it was observed that if experts are appointed as supervisors to different workers, then it yielded better results than a supervisor with less knowledge in his line of work. This was how specialization evolved.
On the basis of experiments: One organisation's structure might be different from the other. So, through different experiments the suitability of the structure can be understood. Suppose, the degree of 'centralization' can be different from one company to other according to the size and volume of a company. What might work for a smaller company, might not work for a bigger one. This can only be understood by experimenting with the existing structure.