Taking something that is not yours is really illegal may it be bitcoin or anything that you take without any authority from the owner. In the case you've given wherein you accidentally have bitcoin in your wallet upon generating it and you don't know who gave it then it is not stealing because there is no intention. But a chance of this happening is near to impossible.