I did a hard-reset, wiped everything everywhere, reinstalled firmware and changed SD card. However, the phone still works extremely slowly, not as when it was bought. What can wear out in phone? Inner flash memory or something else?
This is likely to be caused by one (or both) of two things.
1: Your phone does not have TRIM support - something that was only recently added in 4.3. This makes some devices slow down significantly over time - notably the 2012 Nexus 7 - and they stay slow even after a factory reset.
2: Aging flash. Depending on the quality, type and age of your device's flash memory, it may be deteriorating and you could be losing performance because of this. Note that you won't usually lose any noticeable speed or storage over the life of most flash products, but that depends on a lot of factors.
These are two likely culprits, but it really could be other things as well. We would need to know more about your device, more about the software you're running, things like the brand and model of your SD Card, phone, etc. Your question gives almost no information about any of this.