Why did Allah create stupid and smart people?

I'm not sure what you mean by stupid but I'll assume you mean those who are mentally weaker.

Different people have different strengths which vary in intensity. God expects from his servants based on their strength and will question them to the limit of their strength. If I am one who is able to progress fast even though I may show laziness in my work while someone else who strives very hard, may not be able to progress at the same speed. God looks at how much a person strives not based on their strength. For example if you were to give your child $100 you'll ask them what they did with it and if you were to give $1000, again you'll similarly ask what they did with it. God similarly only questions a person based on what strength they have been given