But my question still exists that why do they generated. There must be some reason of harmonics generation.
It is said that square wave consists of multiple sine waves i.e harmonics but in 555 timers square wave is simply generated by switching then where do these harmonics (sine waves) come in.
I believe, the problem tahir4awan has, is much more simple - and I'll try to answer as follows.
Harmonics are NOT "generated". They are "only" results from applying mathematics to any periodic signal.
Take, for a example, a pure sinewave. If imposed on a non-linear transfer curve (diode or transistor) the resulting signal is not 100% sinusoidal anymore but distorted.
Now comes mathematics: FOURIER has shown that each periodic non-sinusoidal wave can be thought of a superposition of various 100% clean sinusoidal signals of different frequencies, amplitudes and (eventually) phases. And it turns out that these different frequencies all are related to a fundamental frequency by factors 2,3,4,.....
And these frequency components are called "harmonics".
As another example:
A squarewave can be generated either with a "squarewave generator" (timer, or any other circuitry) or via superposition of (theoretically) an infinite number of sinusoidal oscillators generating f, 3f, 5f, 7f....., all with amplitudes according to FOURIER series. In the first case, no harmonics are "generated" but it is something like "as if".....
(In the above example for an ideal squarewave no
even harmonics are present)
Does this answer your question?